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.
19 #include <folly/Format.h>
20 #include <folly/io/async/SSLContext.h>
22 #include <glog/logging.h>
27 struct SSLCommonOptions {
29 * Return the cipher list recommended for this options configuration.
31 static const std::vector<std::string>& getCipherList();
34 * Return the list of signature algorithms recommended for this options
37 static const std::vector<std::string>& getSignatureAlgorithms();
40 * Set common parameters on a client SSL context, for example,
41 * ciphers, signature algorithms, verification options, and client EC curves.
42 * @param ctx The SSL Context to which to apply the options.
44 static void setClientOptions(SSLContext& ctx);
47 template <typename TSSLOptions>
48 void setCipherSuites(SSLContext& ctx) {
50 ctx.setCipherList(TSSLOptions::getCipherList());
51 } catch (std::runtime_error const& e) {
52 LOG(DFATAL) << exceptionStr(e);
56 template <typename TSSLOptions>
57 void setSignatureAlgorithms(SSLContext& ctx) {
59 ctx.setSignatureAlgorithms(TSSLOptions::getSignatureAlgorithms());
60 } catch (std::runtime_error const& e) {
61 LOG(DFATAL) << exceptionStr(e);