proxygen
fizz::server::FizzServerContext Class Reference

#include <FizzServerContext.h>

Public Member Functions

 FizzServerContext ()
 
virtual ~FizzServerContext ()=default
 
void setSupportedVersions (std::vector< ProtocolVersion > versions)
 
const auto & getSupportedVersions () const
 
void setSupportedCiphers (std::vector< std::vector< CipherSuite >> ciphers)
 
const auto & getSupportedCiphers () const
 
void setSupportedSigSchemes (std::vector< SignatureScheme > schemes)
 
const auto & getSupportedSigSchemes () const
 
void setSupportedGroups (std::vector< NamedGroup > groups)
 
const auto & getSupportedGroups () const
 
void setSupportedPskModes (std::vector< PskKeyExchangeMode > modes)
 
const auto & getSupportedPskModes () const
 
void setClientAuthMode (ClientAuthMode authmode)
 
ClientAuthMode getClientAuthMode () const
 
void setVersionFallbackEnabled (bool enabled)
 
bool getVersionFallbackEnabled () const
 
void setSupportedAlpns (std::vector< std::string > protocols)
 
folly::Optional< std::stringnegotiateAlpn (const std::vector< std::string > &clientProtocols, const folly::Optional< std::string > &zeroRttAlpn) const
 
void setTicketCipher (std::shared_ptr< TicketCipher > ticketCipher)
 
const TicketCiphergetTicketCipher () const
 
void setCookieCipher (std::shared_ptr< CookieCipher > cookieCipher)
 
const CookieCiphergetCookieCipher () const
 
void setCertManager (std::unique_ptr< CertManager > manager)
 
void setClientCertVerifier (std::shared_ptr< const CertificateVerifier > verifier)
 
const std::shared_ptr< const CertificateVerifier > & getClientCertVerifier () const
 
folly::Optional< std::pair< std::shared_ptr< SelfCert >, SignatureScheme > > getCert (const folly::Optional< std::string > &sni, const std::vector< SignatureScheme > &peerSigSchemes) const
 
std::shared_ptr< SelfCertgetCert (const std::string &identity) const
 
void setEarlyDataSettings (bool acceptEarlyData, ClockSkewTolerance clockSkewTolerance, const std::shared_ptr< ReplayCache > &replayCache)
 
bool getAcceptEarlyData (ProtocolVersion version) const
 
ClockSkewTolerance getClockSkewTolerance () const
 
ReplayCachegetReplayCache () const
 
void setEarlyDataFbOnly (bool fbOnly)
 
void setMaxEarlyDataSize (uint32_t maxEarlyDataSize)
 
uint32_t getMaxEarlyDataSize () const
 
void setFactory (std::unique_ptr< Factory > factory)
 
const FactorygetFactory () const
 
void setSendNewSessionTicket (bool sendNewSessionTicket)
 
bool getSendNewSessionTicket () const
 
void setSupportedCompressionAlgorithms (std::vector< CertificateCompressionAlgorithm > algos)
 
const auto & getSupportedCompressionAlgorithms () const
 

Private Attributes

std::unique_ptr< Factoryfactory_
 
std::shared_ptr< TicketCipherticketCipher_
 
std::shared_ptr< CookieCiphercookieCipher_
 
std::unique_ptr< CertManagercertManager_
 
std::shared_ptr< const CertificateVerifierclientCertVerifier_
 
std::vector< ProtocolVersionsupportedVersions_ = {ProtocolVersion::tls_1_3}
 
std::vector< std::vector< CipherSuite > > supportedCiphers_
 
std::vector< SignatureSchemesupportedSigSchemes_
 
std::vector< NamedGroupsupportedGroups_
 
std::vector< PskKeyExchangeModesupportedPskModes_
 
std::vector< std::stringsupportedAlpns_
 
bool versionFallbackEnabled_ {false}
 
ClientAuthMode clientAuthMode_ {ClientAuthMode::None}
 
bool acceptEarlyData_ {false}
 
uint32_t maxEarlyDataSize_ {std::numeric_limits<uint32_t>::max()}
 
ClockSkewTolerance clockSkewTolerance_
 
std::shared_ptr< ReplayCachereplayCache_
 
std::vector< CertificateCompressionAlgorithmsupportedCompressionAlgos_
 
bool earlyDataFbOnly_ {false}
 
bool sendNewSessionTicket_ {true}
 

Detailed Description

Definition at line 45 of file FizzServerContext.h.

Constructor & Destructor Documentation

fizz::server::FizzServerContext::FizzServerContext ( )
inline

Definition at line 47 of file FizzServerContext.h.

47 : factory_(std::make_unique<Factory>()) {}
std::unique_ptr< Factory > factory_
virtual fizz::server::FizzServerContext::~FizzServerContext ( )
virtualdefault

Member Function Documentation

folly::Optional<std::pair<std::shared_ptr<SelfCert>, SignatureScheme> > fizz::server::FizzServerContext::getCert ( const folly::Optional< std::string > &  sni,
const std::vector< SignatureScheme > &  peerSigSchemes 
) const
inline

Chooses a certificate based on given sni and peer signature schemes.

Definition at line 192 of file FizzServerContext.h.

Referenced by fizz::sm::chooseCert(), and fizz::server::TicketCodec< Storage >::decode().

194  {
195  return certManager_->getCert(sni, supportedSigSchemes_, peerSigSchemes);
196  }
std::vector< SignatureScheme > supportedSigSchemes_
std::unique_ptr< CertManager > certManager_
std::shared_ptr<SelfCert> fizz::server::FizzServerContext::getCert ( const std::string identity) const
inline

Return a certificate that matches identity. Will return nullptr if a matching certificate is not found.

Definition at line 202 of file FizzServerContext.h.

202  {
203  return certManager_->getCert(identity);
204  }
std::unique_ptr< CertManager > certManager_
ClientAuthMode fizz::server::FizzServerContext::getClientAuthMode ( ) const
inline

Definition at line 107 of file FizzServerContext.h.

Referenced by fizz::sm::generateTicket(), and fizz::sm::getCertificateRequest().

107  {
108  return clientAuthMode_;
109  }
const std::shared_ptr<const CertificateVerifier>& fizz::server::FizzServerContext::getClientCertVerifier ( ) const
inline

Definition at line 183 of file FizzServerContext.h.

Referenced by fizz::sm::generateTicket(), and fizz::sm::getCertificateRequest().

184  {
185  return clientCertVerifier_;
186  }
std::shared_ptr< const CertificateVerifier > clientCertVerifier_
ClockSkewTolerance fizz::server::FizzServerContext::getClockSkewTolerance ( ) const
inline

Definition at line 229 of file FizzServerContext.h.

Referenced by fizz::sm::getCertificateRequest().

229  {
230  return clockSkewTolerance_;
231  }
ClockSkewTolerance clockSkewTolerance_
const CookieCipher* fizz::server::FizzServerContext::getCookieCipher ( ) const
inline

Definition at line 164 of file FizzServerContext.h.

Referenced by fizz::sm::getCertificateRequest().

164  {
165  return cookieCipher_.get();
166  }
std::shared_ptr< CookieCipher > cookieCipher_
const Factory* fizz::server::FizzServerContext::getFactory ( ) const
inline

Definition at line 258 of file FizzServerContext.h.

Referenced by fizz::sm::generateTicket(), and fizz::sm::getCertificateRequest().

258  {
259  return factory_.get();
260  }
std::unique_ptr< Factory > factory_
uint32_t fizz::server::FizzServerContext::getMaxEarlyDataSize ( ) const
inline

Definition at line 248 of file FizzServerContext.h.

Referenced by fizz::sm::writeNewSessionTicket().

248  {
249  return maxEarlyDataSize_;
250  }
ReplayCache* fizz::server::FizzServerContext::getReplayCache ( ) const
inline

Definition at line 232 of file FizzServerContext.h.

Referenced by fizz::sm::getCertificateRequest().

232  {
233  return replayCache_.get();
234  }
std::shared_ptr< ReplayCache > replayCache_
bool fizz::server::FizzServerContext::getSendNewSessionTicket ( ) const
inline

Definition at line 272 of file FizzServerContext.h.

Referenced by fizz::sm::generateTicket().

272  {
273  return sendNewSessionTicket_;
274  }
const auto& fizz::server::FizzServerContext::getSupportedCiphers ( ) const
inline

Definition at line 66 of file FizzServerContext.h.

Referenced by fizz::sm::getCertificateRequest().

66  {
67  return supportedCiphers_;
68  }
std::vector< std::vector< CipherSuite > > supportedCiphers_
const auto& fizz::server::FizzServerContext::getSupportedCompressionAlgorithms ( ) const
inline

Definition at line 285 of file FizzServerContext.h.

Referenced by fizz::sm::getCertificate().

285  {
287  }
std::vector< CertificateCompressionAlgorithm > supportedCompressionAlgos_
const auto& fizz::server::FizzServerContext::getSupportedGroups ( ) const
inline

Definition at line 86 of file FizzServerContext.h.

Referenced by fizz::sm::getCertificateRequest().

86  {
87  return supportedGroups_;
88  }
std::vector< NamedGroup > supportedGroups_
const auto& fizz::server::FizzServerContext::getSupportedPskModes ( ) const
inline

Definition at line 96 of file FizzServerContext.h.

Referenced by fizz::sm::getCertificateRequest().

96  {
97  return supportedPskModes_;
98  }
std::vector< PskKeyExchangeMode > supportedPskModes_
const auto& fizz::server::FizzServerContext::getSupportedSigSchemes ( ) const
inline
const auto& fizz::server::FizzServerContext::getSupportedVersions ( ) const
inline

Definition at line 56 of file FizzServerContext.h.

Referenced by fizz::sm::getCertificateRequest().

56  {
57  return supportedVersions_;
58  }
std::vector< ProtocolVersion > supportedVersions_
const TicketCipher* fizz::server::FizzServerContext::getTicketCipher ( ) const
inline

Definition at line 153 of file FizzServerContext.h.

Referenced by fizz::sm::generateTicket(), and fizz::sm::getCertificateRequest().

153  {
154  return ticketCipher_.get();
155  }
std::shared_ptr< TicketCipher > ticketCipher_
bool fizz::server::FizzServerContext::getVersionFallbackEnabled ( ) const
inline

Definition at line 119 of file FizzServerContext.h.

Referenced by fizz::sm::getCertificateRequest().

119  {
121  }
folly::Optional<std::string> fizz::server::FizzServerContext::negotiateAlpn ( const std::vector< std::string > &  clientProtocols,
const folly::Optional< std::string > &  zeroRttAlpn 
) const
inline

Negotaitate a ALPN protocol given a client's offer. zeroRttAlpn will be set to the protocol used for early data if sent by the client.

Definition at line 134 of file FizzServerContext.h.

References fizz::server::negotiate().

Referenced by fizz::sm::negotiateAlpn().

136  {
137  // If we support the zero rtt protocol we select it.
138  if (zeroRttAlpn &&
139  std::find(
140  supportedAlpns_.begin(), supportedAlpns_.end(), *zeroRttAlpn) !=
141  supportedAlpns_.end()) {
142  return zeroRttAlpn;
143  }
144  return negotiate(supportedAlpns_, clientProtocols);
145  }
std::vector< std::string > supportedAlpns_
folly::Optional< T > negotiate(const std::vector< std::vector< T >> &serverPref, const std::vector< T > &clientPref)
Definition: Negotiator.h:22
void fizz::server::FizzServerContext::setCertManager ( std::unique_ptr< CertManager manager)
inline

Sets the CertManager to use.

Definition at line 171 of file FizzServerContext.h.

References folly::gen::move.

171  {
172  certManager_ = std::move(manager);
173  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< CertManager > certManager_
void fizz::server::FizzServerContext::setClientAuthMode ( ClientAuthMode  authmode)
inline

Set whether to request client authentication.

Definition at line 103 of file FizzServerContext.h.

103  {
104  clientAuthMode_ = authmode;
105  }
void fizz::server::FizzServerContext::setClientCertVerifier ( std::shared_ptr< const CertificateVerifier verifier)
inline

Sets the certificate verifier to use for client authentication

Definition at line 178 of file FizzServerContext.h.

References folly::gen::move.

179  {
180  clientCertVerifier_ = std::move(verifier);
181  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::shared_ptr< const CertificateVerifier > clientCertVerifier_
void fizz::server::FizzServerContext::setCookieCipher ( std::shared_ptr< CookieCipher cookieCipher)
inline

Sets the cookie cipher to use. Stateless client retries will be rejected if not set.

Definition at line 161 of file FizzServerContext.h.

References folly::gen::move.

161  {
162  cookieCipher_ = std::move(cookieCipher);
163  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::shared_ptr< CookieCipher > cookieCipher_
void fizz::server::FizzServerContext::setEarlyDataFbOnly ( bool  fbOnly)
inline

Definition at line 236 of file FizzServerContext.h.

236  {
237  earlyDataFbOnly_ = fbOnly;
238  }
void fizz::server::FizzServerContext::setEarlyDataSettings ( bool  acceptEarlyData,
ClockSkewTolerance  clockSkewTolerance,
const std::shared_ptr< ReplayCache > &  replayCache 
)
inline

Sets the early data settings.

Definition at line 209 of file FizzServerContext.h.

212  {
213  acceptEarlyData_ = acceptEarlyData;
214  clockSkewTolerance_ = clockSkewTolerance;
215  replayCache_ = replayCache;
216  }
std::shared_ptr< ReplayCache > replayCache_
ClockSkewTolerance clockSkewTolerance_
void fizz::server::FizzServerContext::setFactory ( std::unique_ptr< Factory factory)
inline

Set the factory to use. Should generally only be changed for testing.

Definition at line 255 of file FizzServerContext.h.

References folly::gen::move.

255  {
256  factory_ = std::move(factory);
257  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< Factory > factory_
void fizz::server::FizzServerContext::setMaxEarlyDataSize ( uint32_t  maxEarlyDataSize)
inline

Sets the max_early_data_size to advertise when sending early data compatible tickets. This limit is currently not enforced when accepting early data.

Definition at line 245 of file FizzServerContext.h.

245  {
246  maxEarlyDataSize_ = maxEarlyDataSize;
247  }
void fizz::server::FizzServerContext::setSendNewSessionTicket ( bool  sendNewSessionTicket)
inline

Fizz will automatically send NewSessionTicket before reporting handshake success if this is true. Application can use the writeNewSessionTicket API alternatively if this is set to false. Default is true.

Definition at line 269 of file FizzServerContext.h.

269  {
270  sendNewSessionTicket_ = sendNewSessionTicket;
271  }
void fizz::server::FizzServerContext::setSupportedAlpns ( std::vector< std::string protocols)
inline

Sets the supported ALPN supported protocols, in preference order.

Definition at line 126 of file FizzServerContext.h.

References folly::gen::move.

126  {
127  supportedAlpns_ = std::move(protocols);
128  }
std::vector< std::string > supportedAlpns_
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void fizz::server::FizzServerContext::setSupportedCiphers ( std::vector< std::vector< CipherSuite >>  ciphers)
inline

Set the supported ciphers, in preference order.

Definition at line 63 of file FizzServerContext.h.

References folly::gen::move.

63  {
64  supportedCiphers_ = std::move(ciphers);
65  }
std::vector< std::vector< CipherSuite > > supportedCiphers_
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void fizz::server::FizzServerContext::setSupportedCompressionAlgorithms ( std::vector< CertificateCompressionAlgorithm algos)
inline

Set supported cert compression algorithms. Note: It is expected that any certificate used has been initialized with compressors corresponding to the algorithms set here.

Definition at line 281 of file FizzServerContext.h.

282  {
284  }
std::vector< CertificateCompressionAlgorithm > supportedCompressionAlgos_
void fizz::server::FizzServerContext::setSupportedGroups ( std::vector< NamedGroup groups)
inline

Set the supported named groups, in preference order.

Definition at line 83 of file FizzServerContext.h.

References folly::gen::move.

83  {
84  supportedGroups_ = std::move(groups);
85  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::vector< NamedGroup > supportedGroups_
void fizz::server::FizzServerContext::setSupportedPskModes ( std::vector< PskKeyExchangeMode modes)
inline

Set the supported psk modes, in preference order.

Definition at line 93 of file FizzServerContext.h.

References folly::gen::move.

93  {
95  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::vector< PskKeyExchangeMode > supportedPskModes_
void fizz::server::FizzServerContext::setSupportedSigSchemes ( std::vector< SignatureScheme schemes)
inline

Set the supported signature schemes, in preference order.

Definition at line 73 of file FizzServerContext.h.

References folly::gen::move.

73  {
75  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::vector< SignatureScheme > supportedSigSchemes_
void fizz::server::FizzServerContext::setSupportedVersions ( std::vector< ProtocolVersion versions)
inline

Set the supported protocol versions, in preference order.

Definition at line 53 of file FizzServerContext.h.

References folly::gen::move.

53  {
54  supportedVersions_ = std::move(versions);
55  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::vector< ProtocolVersion > supportedVersions_
void fizz::server::FizzServerContext::setTicketCipher ( std::shared_ptr< TicketCipher ticketCipher)
inline

Sets the ticket cipher to use. Resumption will be disabled if not set.

Definition at line 150 of file FizzServerContext.h.

References folly::gen::move.

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

150  {
151  ticketCipher_ = std::move(ticketCipher);
152  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::shared_ptr< TicketCipher > ticketCipher_
void fizz::server::FizzServerContext::setVersionFallbackEnabled ( bool  enabled)
inline

Set whether to attempt fallback to another implementation if no supported version match is found. If enabled connect callbacks should implement fizzHandshakeAttemptFallback.

Definition at line 116 of file FizzServerContext.h.

116  {
117  versionFallbackEnabled_ = enabled;
118  }

Member Data Documentation

bool fizz::server::FizzServerContext::acceptEarlyData_ {false}
private

Definition at line 321 of file FizzServerContext.h.

std::unique_ptr<CertManager> fizz::server::FizzServerContext::certManager_
private

Definition at line 295 of file FizzServerContext.h.

ClientAuthMode fizz::server::FizzServerContext::clientAuthMode_ {ClientAuthMode::None}
private

Definition at line 319 of file FizzServerContext.h.

std::shared_ptr<const CertificateVerifier> fizz::server::FizzServerContext::clientCertVerifier_
private

Definition at line 296 of file FizzServerContext.h.

ClockSkewTolerance fizz::server::FizzServerContext::clockSkewTolerance_
private

Definition at line 323 of file FizzServerContext.h.

std::shared_ptr<CookieCipher> fizz::server::FizzServerContext::cookieCipher_
private

Definition at line 293 of file FizzServerContext.h.

bool fizz::server::FizzServerContext::earlyDataFbOnly_ {false}
private

Definition at line 328 of file FizzServerContext.h.

std::unique_ptr<Factory> fizz::server::FizzServerContext::factory_
private

Definition at line 290 of file FizzServerContext.h.

uint32_t fizz::server::FizzServerContext::maxEarlyDataSize_ {std::numeric_limits<uint32_t>::max()}
private

Definition at line 322 of file FizzServerContext.h.

std::shared_ptr<ReplayCache> fizz::server::FizzServerContext::replayCache_
private

Definition at line 324 of file FizzServerContext.h.

bool fizz::server::FizzServerContext::sendNewSessionTicket_ {true}
private

Definition at line 330 of file FizzServerContext.h.

std::vector<std::string> fizz::server::FizzServerContext::supportedAlpns_
private

Definition at line 316 of file FizzServerContext.h.

std::vector<std::vector<CipherSuite> > fizz::server::FizzServerContext::supportedCiphers_
private
Initial value:

Definition at line 299 of file FizzServerContext.h.

std::vector<CertificateCompressionAlgorithm> fizz::server::FizzServerContext::supportedCompressionAlgos_
private

Definition at line 326 of file FizzServerContext.h.

std::vector<NamedGroup> fizz::server::FizzServerContext::supportedGroups_
private
Initial value:

Definition at line 311 of file FizzServerContext.h.

std::vector<PskKeyExchangeMode> fizz::server::FizzServerContext::supportedPskModes_
private
Initial value:

Definition at line 313 of file FizzServerContext.h.

std::vector<SignatureScheme> fizz::server::FizzServerContext::supportedSigSchemes_
private
std::vector<ProtocolVersion> fizz::server::FizzServerContext::supportedVersions_ = {ProtocolVersion::tls_1_3}
private

Definition at line 298 of file FizzServerContext.h.

std::shared_ptr<TicketCipher> fizz::server::FizzServerContext::ticketCipher_
private

Definition at line 292 of file FizzServerContext.h.

bool fizz::server::FizzServerContext::versionFallbackEnabled_ {false}
private

Definition at line 318 of file FizzServerContext.h.


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