33 std::unique_ptr<fizz::server::CertManager> createCertManager(
34 const ServerSocketConfig&
config) {
35 auto certMgr = std::make_unique<fizz::server::CertManager>();
36 auto loadedCert =
false;
37 for (
const auto& sslConfig : config.sslContextConfigs) {
38 for (
const auto& cert : sslConfig.certificates) {
40 auto x509Chain = FizzUtil::readChainFile(cert.certPath);
41 auto pkey = FizzUtil::readPrivateKey(cert.keyPath, cert.passwordPath);
44 certMgr->addCert(
std::move(selfCert), sslConfig.isDefault);
46 }
catch (
const std::runtime_error& ex) {
48 "Failed to load cert or key at key path {}, cert path {}",
51 if (config.strictSSL) {
52 throw std::runtime_error(ex.what() + msg);
54 LOG(ERROR) << msg << ex.what();
66 std::shared_ptr<fizz::server::FizzServerContext>
69 std::unique_ptr<fizz::server::CertManager> certMgr) {
74 certMgr = createCertManager(config);
80 auto ctx = std::make_shared<fizz::server::FizzServerContext>();
81 ctx->setSupportedVersions({ProtocolVersion::tls_1_3,
82 ProtocolVersion::tls_1_3_28,
83 ProtocolVersion::tls_1_3_26});
84 ctx->setVersionFallbackEnabled(
true);
91 ctx->setSupportedAlpns(FizzUtil::getAlpnsFromNpnList(
list));
96 case folly::SSLContext::SSLVerifyPeerEnum::VERIFY_REQ_CLIENT_CERT:
97 ctx->setClientAuthMode(ClientAuthMode::Required);
99 case folly::SSLContext::SSLVerifyPeerEnum::VERIFY:
100 ctx->setClientAuthMode(ClientAuthMode::Optional);
103 ctx->setClientAuthMode(ClientAuthMode::None);
107 if (!caFile.empty()) {
108 auto verifier = DefaultCertificateVerifier::createFromCAFile(
109 VerificationContext::Server, caFile);
110 ctx->setClientCertVerifier(
std::move(verifier));
std::string sformat(StringPiece fmt, Args &&...args)
constexpr detail::Map< Move > move
static std::shared_ptr< fizz::server::FizzServerContext > createFizzContext(const wangle::ServerSocketConfig &config, std::unique_ptr< fizz::server::CertManager > certMgr=nullptr)
Encoder::MutableCompressedList list
std::vector< SSLContextConfig > sslContextConfigs