2 * Copyright 2004-present Facebook, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "SSLOptions.h"
22 const std::vector<std::string>& SSLCommonOptions::getCipherList() {
23 static const std::vector<std::string> kCommonCipherList = {
24 "ECDHE-ECDSA-AES128-GCM-SHA256",
25 "ECDHE-RSA-AES128-GCM-SHA256",
26 "ECDHE-ECDSA-AES256-GCM-SHA384",
27 "ECDHE-RSA-AES256-GCM-SHA384",
28 "ECDHE-ECDSA-AES256-SHA",
29 "ECDHE-RSA-AES256-SHA",
30 "ECDHE-ECDSA-AES128-SHA",
31 "ECDHE-RSA-AES128-SHA",
32 "ECDHE-RSA-AES256-SHA384",
37 return kCommonCipherList;
40 const std::vector<std::string>& SSLCommonOptions::getSignatureAlgorithms() {
41 static const std::vector<std::string> kCommonSigAlgs = {
51 return kCommonSigAlgs;
54 void SSLCommonOptions::setClientOptions(SSLContext& ctx) {
55 #ifdef SSL_MODE_HANDSHAKE_CUTTHROUGH
56 ctx.enableFalseStart();
59 X509VerifyParam param(X509_VERIFY_PARAM_new());
60 X509_VERIFY_PARAM_set_flags(param.get(), X509_V_FLAG_X509_STRICT);
62 ctx.setX509VerifyParam(param);
63 } catch (std::runtime_error const& e) {
64 LOG(DFATAL) << exceptionStr(e);
68 ctx.setClientECCurvesList({"P-256", "P-384"});
69 } catch (std::runtime_error const& e) {
70 LOG(DFATAL) << exceptionStr(e);
73 setCipherSuites<SSLCommonOptions>(ctx);
74 setSignatureAlgorithms<SSLCommonOptions>(ctx);