proxygen
wangle::ServerSSLContext Class Reference

#include <ServerSSLContext.h>

Inheritance diagram for wangle::ServerSSLContext:
folly::SSLContext

Public Member Functions

 ServerSSLContext (SSLVersion version=TLSv1)
 
virtual ~ServerSSLContext () override=default
 
void setupTicketManager (const TLSTicketKeySeeds *ticketSeeds, const SSLContextConfig &ctxConfig, SSLStats *stats)
 
void setupSessionCache (const SSLContextConfig &ctxConfig, const SSLCacheOptions &cacheOptions, const std::shared_ptr< SSLCacheProvider > &externalCache, const std::string &sessionIdContext, SSLStats *stats)
 
TLSTicketKeyManagergetTicketManager ()
 
SSLSessionCacheManagergetSessionCacheManager ()
 
- Public Member Functions inherited from folly::SSLContext
 SSLContext (SSLVersion version=TLSv1)
 
virtual ~SSLContext ()
 
virtual void ciphers (const std::string &ciphers)
 
virtual void setCiphersOrThrow (const std::string &ciphers)
 
template<typename Iterator >
void setCipherList (Iterator ibegin, Iterator iend)
 
template<typename Container >
void setCipherList (const Container &cipherList)
 
template<typename Value >
void setCipherList (const std::initializer_list< Value > &cipherList)
 
template<typename Iterator >
void setSignatureAlgorithms (Iterator ibegin, Iterator iend)
 
template<typename Container >
void setSignatureAlgorithms (const Container &sigalgs)
 
template<typename Value >
void setSignatureAlgorithms (const std::initializer_list< Value > &sigalgs)
 
void setClientECCurvesList (const std::vector< std::string > &ecCurves)
 
void setServerECCurve (const std::string &curveName)
 
void setX509VerifyParam (const ssl::X509VerifyParam &x509VerifyParam)
 
virtual void setVerificationOption (const SSLVerifyPeerEnum &verifyPeer)
 
virtual bool needsPeerVerification ()
 
virtual int getVerificationMode ()
 
virtual void authenticate (bool checkPeerCert, bool checkPeerName, const std::string &peerName=std::string())
 
virtual void loadCertificate (const char *path, const char *format="PEM")
 
virtual void loadCertificateFromBufferPEM (folly::StringPiece cert)
 
virtual void loadPrivateKey (const char *path, const char *format="PEM")
 
virtual void loadPrivateKeyFromBufferPEM (folly::StringPiece pkey)
 
virtual void loadCertKeyPairFromBufferPEM (folly::StringPiece cert, folly::StringPiece pkey)
 
virtual void loadCertKeyPairFromFiles (const char *certPath, const char *keyPath, const char *certFormat="PEM", const char *keyFormat="PEM")
 
virtual bool isCertKeyPairValid () const
 
virtual void loadTrustedCertificates (const char *path)
 
virtual void loadTrustedCertificates (X509_STORE *store)
 
virtual void loadClientCAList (const char *path)
 
virtual void passwordCollector (std::shared_ptr< PasswordCollector > collector)
 
virtual std::shared_ptr< PasswordCollectorpasswordCollector ()
 
SSL * createSSL () const
 
void setSessionCacheContext (const std::string &context)
 
void setOptions (long options)
 
SSL_CTX * getSSLCtx () const
 
bool checkPeerName ()
 
std::string peerFixedName ()
 
void sslAcceptRunner (std::unique_ptr< SSLAcceptRunner > runner)
 
const SSLAcceptRunnersslAcceptRunner ()
 

Private Attributes

std::unique_ptr< TLSTicketKeyManagerticketManager_
 
std::unique_ptr< SSLSessionCacheManagersessionCacheManager_
 

Additional Inherited Members

- Public Types inherited from folly::SSLContext
enum  SSLVersion { SSLv2, SSLv3, TLSv1, TLSv1_2 }
 
enum  SSLVerifyPeerEnum { USE_CTX, VERIFY, VERIFY_REQ_CLIENT_CERT, NO_VERIFY }
 
using ClientProtocolFilterCallback = bool(*)(unsigned char **, unsigned int *, const unsigned char *, unsigned int)
 
- Static Public Member Functions inherited from folly::SSLContext
static std::string getErrors ()
 
static int getVerificationMode (const SSLVerifyPeerEnum &verifyPeer)
 
static std::string getErrors (int errnoCopy)
 
static bool matchName (const char *host, const char *pattern, int size)
 
static void initializeOpenSSL ()
 
- Protected Attributes inherited from folly::SSLContext
SSL_CTX * ctx_
 

Detailed Description

Definition at line 42 of file ServerSSLContext.h.

Constructor & Destructor Documentation

wangle::ServerSSLContext::ServerSSLContext ( SSLVersion  version = TLSv1)
explicit

Definition at line 30 of file ServerSSLContext.cpp.

References folly::SSLContext::setSessionCacheContext().

32  setSessionCacheContext("ServerSSLContext");
33 }
ProtocolVersion version
void setSessionCacheContext(const std::string &context)
Definition: SSLContext.cpp:526
virtual wangle::ServerSSLContext::~ServerSSLContext ( )
overridevirtualdefault

Member Function Documentation

SSLSessionCacheManager* wangle::ServerSSLContext::getSessionCacheManager ( )
inline

Definition at line 66 of file ServerSSLContext.h.

66  {
67  return sessionCacheManager_.get();
68  }
std::unique_ptr< SSLSessionCacheManager > sessionCacheManager_
TLSTicketKeyManager* wangle::ServerSSLContext::getTicketManager ( )
inline

Definition at line 61 of file ServerSSLContext.h.

61  {
62  return ticketManager_.get();
63  }
std::unique_ptr< TLSTicketKeyManager > ticketManager_
void wangle::ServerSSLContext::setupSessionCache ( const SSLContextConfig ctxConfig,
const SSLCacheOptions cacheOptions,
const std::shared_ptr< SSLCacheProvider > &  externalCache,
const std::string sessionIdContext,
SSLStats stats 
)

Definition at line 57 of file ServerSSLContext.cpp.

References folly::SSLContext::getSSLCtx(), wangle::SSLCacheOptions::maxSSLCacheSize, wangle::SSLContextConfig::sessionCacheEnabled, sessionCacheManager_, wangle::SSLCacheOptions::sslCacheFlushSize, and wangle::SSLCacheOptions::sslCacheTimeout.

62  {
63  // the internal cache never does what we want (per-thread-per-vip).
64  // Disable it. SSLSessionCacheManager will set it appropriately.
65  SSL_CTX_set_session_cache_mode(getSSLCtx(), SSL_SESS_CACHE_OFF);
66  SSL_CTX_set_timeout(getSSLCtx(), cacheOptions.sslCacheTimeout.count());
67  if (ctxConfig.sessionCacheEnabled &&
68  cacheOptions.maxSSLCacheSize > 0 &&
69  cacheOptions.sslCacheFlushSize > 0) {
70  sessionCacheManager_ = std::make_unique<SSLSessionCacheManager>(
71  cacheOptions.maxSSLCacheSize,
72  cacheOptions.sslCacheFlushSize,
73  this,
74  sessionIdContext,
75  stats,
76  externalCache);
77  } else {
78  sessionCacheManager_.reset();
79  }
80 }
SSL_CTX * getSSLCtx() const
Definition: SSLContext.h:503
std::unique_ptr< SSLSessionCacheManager > sessionCacheManager_
void wangle::ServerSSLContext::setupTicketManager ( const TLSTicketKeySeeds ticketSeeds,
const SSLContextConfig ctxConfig,
SSLStats stats 
)

Definition at line 35 of file ServerSSLContext.cpp.

References wangle::TLSTicketKeySeeds::currentSeeds, wangle::TLSTicketKeySeeds::newSeeds, wangle::TLSTicketKeySeeds::oldSeeds, OPENSSL_MISSING_FEATURE, wangle::SSLContextConfig::sessionTicketEnabled, folly::SSLContext::setOptions(), and ticketManager_.

38  {
39 #ifdef SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB
40  if (ticketSeeds && ctxConfig.sessionTicketEnabled) {
41  ticketManager_ = std::make_unique<TLSTicketKeyManager>(this, stats);
42  ticketManager_->setTLSTicketKeySeeds(
43  ticketSeeds->oldSeeds,
44  ticketSeeds->currentSeeds,
45  ticketSeeds->newSeeds);
46  } else {
47  setOptions(SSL_OP_NO_TICKET);
48  ticketManager_.reset();
49  }
50 #else
51  if (ticketSeeds && ctxConfig.sessionTicketEnabled) {
52  OPENSSL_MISSING_FEATURE(TLSTicket);
53  }
54 #endif
55 }
void setOptions(long options)
Definition: SSLContext.cpp:590
#define OPENSSL_MISSING_FEATURE(name)
std::unique_ptr< TLSTicketKeyManager > ticketManager_

Member Data Documentation

std::unique_ptr<SSLSessionCacheManager> wangle::ServerSSLContext::sessionCacheManager_
private

Definition at line 72 of file ServerSSLContext.h.

Referenced by setupSessionCache().

std::unique_ptr<TLSTicketKeyManager> wangle::ServerSSLContext::ticketManager_
private

Definition at line 71 of file ServerSSLContext.h.

Referenced by setupTicketManager().


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