proxygen
wangle::FizzConfigUtil Class Reference

#include <FizzConfigUtil.h>

Static Public Member Functions

static std::shared_ptr< fizz::server::FizzServerContextcreateFizzContext (const wangle::ServerSocketConfig &config, std::unique_ptr< fizz::server::CertManager > certMgr=nullptr)
 
template<class TicketCipher >
static std::unique_ptr< TicketCipher > createTicketCipher (const std::vector< std::string > &oldSecrets, const std::vector< std::string > &currentSecrets, const std::vector< std::string > &newSecrets, std::chrono::seconds validity, folly::Optional< std::string > pskContext)
 

Detailed Description

Definition at line 26 of file FizzConfigUtil.h.

Member Function Documentation

std::shared_ptr< fizz::server::FizzServerContext > wangle::FizzConfigUtil::createFizzContext ( const wangle::ServerSocketConfig config,
std::unique_ptr< fizz::server::CertManager certMgr = nullptr 
)
static

Definition at line 67 of file FizzConfigUtil.cpp.

References bm::list, folly::gen::move, wangle::ServerSocketConfig::sslContextConfigs, and verify().

Referenced by wangle::Acceptor::createFizzContext().

69  {
70  if (config.sslContextConfigs.empty()) {
71  return nullptr;
72  }
73  if (!certMgr) {
74  certMgr = createCertManager(config);
75  if (!certMgr) {
76  return nullptr;
77  }
78  }
79 
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);
85  ctx->setCertManager(std::move(certMgr));
86 
87  // Fizz does not yet support randomized next protocols so we use the highest
88  // weighted list on the first context.
89  const auto& list = config.sslContextConfigs.front().nextProtocols;
90  if (!list.empty()) {
91  ctx->setSupportedAlpns(FizzUtil::getAlpnsFromNpnList(list));
92  }
93 
94  auto verify = config.sslContextConfigs.front().clientVerification;
95  switch (verify) {
96  case folly::SSLContext::SSLVerifyPeerEnum::VERIFY_REQ_CLIENT_CERT:
97  ctx->setClientAuthMode(ClientAuthMode::Required);
98  break;
99  case folly::SSLContext::SSLVerifyPeerEnum::VERIFY:
100  ctx->setClientAuthMode(ClientAuthMode::Optional);
101  break;
102  default:
103  ctx->setClientAuthMode(ClientAuthMode::None);
104  }
105 
106  auto caFile = config.sslContextConfigs.front().clientCAFile;
107  if (!caFile.empty()) {
108  auto verifier = DefaultCertificateVerifier::createFromCAFile(
109  VerificationContext::Server, caFile);
110  ctx->setClientCertVerifier(std::move(verifier));
111  }
112 
113  return ctx;
114 }
void verify(int extras)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
Encoder::MutableCompressedList list
std::vector< SSLContextConfig > sslContextConfigs
template<class TicketCipher >
static std::unique_ptr<TicketCipher> wangle::FizzConfigUtil::createTicketCipher ( const std::vector< std::string > &  oldSecrets,
const std::vector< std::string > &  currentSecrets,
const std::vector< std::string > &  newSecrets,
std::chrono::seconds  validity,
folly::Optional< std::string pskContext 
)
inlinestatic

Definition at line 34 of file FizzConfigUtil.h.

References folly::gen::move.

39  {
40  if (currentSecrets.empty()) {
41  return fizz::FizzUtil::createTicketCipher<TicketCipher>(
42  oldSecrets, "", newSecrets, validity, std::move(pskContext));
43  } else {
44  return fizz::FizzUtil::createTicketCipher<TicketCipher>(
45  oldSecrets,
46  currentSecrets.at(0),
47  newSecrets,
48  validity,
49  std::move(pskContext));
50  }
51  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567

The documentation for this class was generated from the following files: