proxygen
wangle::SSLSessionCacheManager Class Reference

#include <SSLSessionCacheManager.h>

Inheritance diagram for wangle::SSLSessionCacheManager:

Public Member Functions

 SSLSessionCacheManager (uint32_t maxCacheSize, uint32_t cacheCullSize, folly::SSLContext *ctx, const std::string &context, SSLStats *stats, const std::shared_ptr< SSLCacheProvider > &externalCache)
 
virtual ~SSLSessionCacheManager ()
 
void onGetSuccess (SSLCacheProvider::CacheContext *cacheCtx, const std::string &value)
 
void onGetSuccess (SSLCacheProvider::CacheContext *cacheCtx, std::unique_ptr< folly::IOBuf > valueBuf)
 
void onGetFailure (SSLCacheProvider::CacheContext *cacheCtx)
 

Static Public Member Functions

static void shutdown ()
 

Private Types

using session_callback_arg_session_id_t = unsigned char *
 

Private Member Functions

int newSession (SSL *ssl, SSL_SESSION *session)
 
void removeSession (SSL_CTX *ctx, SSL_SESSION *session)
 
SSL_SESSION * getSession (SSL *ssl, unsigned char *session_id, int id_len, int *copyflag)
 
void restoreSession (SSLCacheProvider::CacheContext *cacheCtx, const uint8_t *data, size_t length)
 
bool storeCacheRecord (const std::string &sessionId, SSL_SESSION *session)
 
bool lookupCacheRecord (const std::string &sessionId, folly::AsyncSSLSocket *sslSock)
 
void restartSSLAccept (const SSLCacheProvider::CacheContext *cacheCtx)
 

Static Private Member Functions

static std::shared_ptr< ShardedLocalSSLSessionCachegetLocalCache (uint32_t maxCacheSize, uint32_t cacheCullSize)
 
static int newSessionCallback (SSL *ssl, SSL_SESSION *session)
 
static void removeSessionCallback (SSL_CTX *ctx, SSL_SESSION *session)
 
static SSL_SESSION * getSessionCallback (SSL *ssl, session_callback_arg_session_id_t session_id, int id_len, int *copyflag)
 

Private Attributes

folly::SSLContextctx_
 
std::shared_ptr< ShardedLocalSSLSessionCachelocalCache_
 
PendingLookupMap pendingLookups_
 
SSLStatsstats_ {nullptr}
 
std::shared_ptr< SSLCacheProviderexternalCache_
 

Static Private Attributes

static int32_t sExDataIndex_ = -1
 
static std::shared_ptr< ShardedLocalSSLSessionCachesCache_
 
static std::mutex sCacheLock_
 

Detailed Description

SSLSessionCacheManager handles all stateful session caching. There is an instance of this object per SSL VIP per thread, with a 1:1 correlation with SSL_CTX. The cache can work locally or in concert with an external cache to share sessions across instances.

There is a single in memory session cache shared by all VIPs. The cache is split into N buckets (currently 16) with a separate lock per bucket. The VIP ID is hashed and stored as part of the session to handle the (very unlikely) case of session ID collision.

When a new SSL session is created, it is added to the LRU cache and sent to the external cache to be stored. The external cache expiration is equal to the SSL session's expiration.

When a resume request is received, SSLSessionCacheManager first looks in the local LRU cache for the VIP. If there is a miss there, an asynchronous request for this session is dispatched to the external cache. When the external cache query returns, the LRU cache is updated if the session was found, and the SSL_accept call is resumed.

If additional resume requests for the same session ID arrive in the same thread while the request is pending, the 2nd - Nth callers attach to the original external cache requests and are resumed when it comes back. No attempt is made to coalesce external cache requests for the same session ID in different worker threads. Previous work did this, but the complexity was deemed to outweigh the potential savings.

Definition at line 136 of file SSLSessionCacheManager.h.

Member Typedef Documentation

Definition at line 255 of file SSLSessionCacheManager.h.

Constructor & Destructor Documentation

wangle::SSLSessionCacheManager::SSLSessionCacheManager ( uint32_t  maxCacheSize,
uint32_t  cacheCullSize,
folly::SSLContext ctx,
const std::string context,
SSLStats stats,
const std::shared_ptr< SSLCacheProvider > &  externalCache 
)

Constructor. SSL session related callbacks will be set on the underlying SSL_CTX. vipId is assumed to a unique string identifying the VIP and must be the same on all servers that wish to share sessions via the same external cache.

Definition at line 142 of file SSLSessionCacheManager.cpp.

References getLocalCache(), getSessionCallback(), folly::SSLContext::getSSLCtx(), wangle::SSLUtil::getSSLCtxExIndex(), localCache_, newSessionCallback(), removeSessionCallback(), folly::SSLContext::setSessionCacheContext(), and sExDataIndex_.

148  :
149  ctx_(ctx),
150  stats_(stats),
151  externalCache_(externalCache) {
152 
153  SSL_CTX* sslCtx = ctx->getSSLCtx();
154 
156 
157  SSL_CTX_set_ex_data(sslCtx, sExDataIndex_, this);
158  SSL_CTX_sess_set_new_cb(sslCtx, SSLSessionCacheManager::newSessionCallback);
159  SSL_CTX_sess_set_get_cb(sslCtx, SSLSessionCacheManager::getSessionCallback);
160  SSL_CTX_sess_set_remove_cb(sslCtx,
162  if (!FLAGS_dcache_unit_test && !context.empty()) {
163  // Use the passed in context
165  }
166 
167  SSL_CTX_set_session_cache_mode(sslCtx, SSL_SESS_CACHE_NO_INTERNAL
168  | SSL_SESS_CACHE_SERVER);
169 
171  cacheCullSize);
172 }
static SSL_SESSION * getSessionCallback(SSL *ssl, session_callback_arg_session_id_t session_id, int id_len, int *copyflag)
context
Definition: CMakeCache.txt:563
static void removeSessionCallback(SSL_CTX *ctx, SSL_SESSION *session)
static std::shared_ptr< ShardedLocalSSLSessionCache > getLocalCache(uint32_t maxCacheSize, uint32_t cacheCullSize)
static void getSSLCtxExIndex(int *pindex)
Definition: SSLUtil.h:74
SSL_CTX * getSSLCtx() const
Definition: SSLContext.h:503
static int newSessionCallback(SSL *ssl, SSL_SESSION *session)
std::shared_ptr< ShardedLocalSSLSessionCache > localCache_
void setSessionCacheContext(const std::string &context)
Definition: SSLContext.cpp:526
std::shared_ptr< SSLCacheProvider > externalCache_
wangle::SSLSessionCacheManager::~SSLSessionCacheManager ( )
virtual

Definition at line 174 of file SSLSessionCacheManager.cpp.

174  {
175 }

Member Function Documentation

shared_ptr< ShardedLocalSSLSessionCache > wangle::SSLSessionCacheManager::getLocalCache ( uint32_t  maxCacheSize,
uint32_t  cacheCullSize 
)
staticprivate

Get or create the LRU cache for the given VIP ID

Definition at line 182 of file SSLSessionCacheManager.cpp.

References g(), sCache_, and sCacheLock_.

Referenced by SSLSessionCacheManager().

184  {
185 
186  std::lock_guard<std::mutex> g(sCacheLock_);
187  if (!sCache_) {
188  sCache_.reset(new ShardedLocalSSLSessionCache(NUM_CACHE_BUCKETS,
189  maxCacheSize,
190  cacheCullSize));
191  }
192  return sCache_;
193 }
static std::shared_ptr< ShardedLocalSSLSessionCache > sCache_
g_t g(f_t)
SSL_SESSION * wangle::SSLSessionCacheManager::getSession ( SSL *  ssl,
unsigned char *  session_id,
int  id_len,
int *  copyflag 
)
private

Invoked by openssl when a client requests a stateful session resumption. Triggers a lookup in our local cache and potentially an asynchronous request to an external cache.

Definition at line 272 of file SSLSessionCacheManager.cpp.

References externalCache_, folly::AsyncSocket::getFd(), folly::AsyncSSLSocket::getFromSSL(), wangle::SSLUtil::hexlify(), localCache_, lookupCacheRecord(), folly::gen::move, folly::fibers::onFiber(), pendingLookups_, wangle::SSLStats::recordSSLSession(), folly::AsyncSSLSocket::setSessionIDResumed(), stats_, and string.

Referenced by getSessionCallback().

276  {
277  VLOG(7) << "SSL get session callback";
279  bool foreign = false;
280  std::string missReason;
281 
282  if (id_len < MIN_SESSION_ID_LENGTH) {
283  // We didn't generate this session so it's going to be a miss.
284  // This doesn't get logged or counted in the stats.
285  return nullptr;
286  }
287  string sessionId((char*)session_id, id_len);
288 
289  AsyncSSLSocket* sslSocket = AsyncSSLSocket::getFromSSL(ssl);
290 
291  assert(sslSocket != nullptr);
292 
293  // look it up in the local cache first
294  session.reset(localCache_->lookupSession(sessionId));
295 #ifdef SSL_SESSION_CB_WOULD_BLOCK
296  if (session == nullptr && externalCache_) {
297  // external cache might have the session
298  foreign = true;
299  if (!SSL_want_sess_cache_lookup(ssl)) {
300  missReason = "reason: No async cache support;";
301  } else {
302  PendingLookupMap::iterator pit = pendingLookups_.find(sessionId);
303  if (pit == pendingLookups_.end()) {
304  auto result = pendingLookups_.emplace(sessionId, PendingLookup());
305  // initiate fetch
306  VLOG(4) << "Get SSL session [Pending]: Initiate Fetch; fd=" <<
307  sslSocket->getFd() << " id=" << SSLUtil::hexlify(sessionId);
308  if (lookupCacheRecord(sessionId, sslSocket)) {
309  // response is pending
310  *copyflag = SSL_SESSION_CB_WOULD_BLOCK;
311  return nullptr;
312  } else {
313  missReason = "reason: failed to send lookup request;";
314  pendingLookups_.erase(result.first);
315  }
316  } else {
317  // A lookup was already initiated from this thread
318  if (pit->second.request_in_progress) {
319  // Someone else initiated the request, attach
320  VLOG(4) << "Get SSL session [Pending]: Request in progess: attach; "
321  "fd=" << sslSocket->getFd() << " id=" <<
322  SSLUtil::hexlify(sessionId);
323  std::unique_ptr<DelayedDestruction::DestructorGuard> dg(
324  new DelayedDestruction::DestructorGuard(sslSocket));
325  pit->second.waiters.emplace_back(sslSocket, std::move(dg));
326  *copyflag = SSL_SESSION_CB_WOULD_BLOCK;
327  return nullptr;
328  }
329  // request is complete
330  session.reset(
331  pit->second.session); // nullptr if our friend didn't have it
332  if (session) {
333  SSL_SESSION_up_ref(session.get());
334  }
335  }
336  }
337  }
338 #elif FOLLY_OPENSSL_IS_110
339  if (session == nullptr && externalCache_) {
340  foreign = true;
341  DCHECK(folly::fibers::onFiber());
342 
343  try {
344  session = externalCache_->getFuture(sessionId).get();
345  } catch (const std::exception& e) {
346  missReason = folly::to<std::string>("reason: ", e.what(), ";");
347  }
348 
349  if (session) {
350  localCache_->storeSession(sessionId, session.get(), stats_);
351  SSL_SESSION_up_ref(session.get());
352  }
353  }
354 #endif
355 
356  bool hit = (session != nullptr);
357  if (stats_) {
358  stats_->recordSSLSession(false, hit, foreign);
359  }
360  if (hit) {
361  sslSocket->setSessionIDResumed(true);
362  }
363 
364  VLOG(4) << "Get SSL session [" << ((hit) ? "Hit" : "Miss")
365  << "]: " << ((foreign) ? "external" : "local") << " cache; "
366  << missReason << "fd=" << sslSocket->getFd()
367  << " id=" << SSLUtil::hexlify(sessionId);
368 
369  // We already bumped the refcount
370  *copyflag = 0;
371 
372  return session.release();
373 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void setSessionIDResumed(bool resumed)
virtual void recordSSLSession(bool sessionNew, bool sessionHit, bool foreign) noexcept=0
virtual int getFd() const
Definition: AsyncSocket.h:335
std::shared_ptr< ShardedLocalSSLSessionCache > localCache_
const char * string
Definition: Conv.cpp:212
static std::string hexlify(const std::string &binary)
Definition: SSLUtil.h:150
std::unique_ptr< SSL_SESSION, SSLSessionDeleter > SSLSessionUniquePtr
std::shared_ptr< SSLCacheProvider > externalCache_
bool lookupCacheRecord(const std::string &sessionId, folly::AsyncSSLSocket *sslSock)
static AsyncSSLSocket * getFromSSL(const SSL *ssl)
SSL_SESSION * wangle::SSLSessionCacheManager::getSessionCallback ( SSL *  ssl,
session_callback_arg_session_id_t  session_id,
int  id_len,
int *  copyflag 
)
staticprivate

Definition at line 257 of file SSLSessionCacheManager.cpp.

References folly::FATAL, getSession(), and sExDataIndex_.

Referenced by SSLSessionCacheManager().

261  {
262  SSLSessionCacheManager* manager = nullptr;
263  SSL_CTX* ctx = SSL_get_SSL_CTX(ssl);
264  manager = (SSLSessionCacheManager*)SSL_CTX_get_ex_data(ctx, sExDataIndex_);
265 
266  if (manager == nullptr) {
267  LOG(FATAL) << "Null SSLSessionCacheManager in callback";
268  }
269  return manager->getSession(ssl, (unsigned char*)sess_id, id_len, copyflag);
270 }
SSLSessionCacheManager(uint32_t maxCacheSize, uint32_t cacheCullSize, folly::SSLContext *ctx, const std::string &context, SSLStats *stats, const std::shared_ptr< SSLCacheProvider > &externalCache)
bool wangle::SSLSessionCacheManager::lookupCacheRecord ( const std::string sessionId,
folly::AsyncSSLSocket sslSock 
)
private

Lookup a session in the external cache for the specified SSL socket.

Definition at line 387 of file SSLSessionCacheManager.cpp.

References externalCache_.

Referenced by getSession().

388  {
389  auto cacheCtx = new SSLCacheProvider::CacheContext();
390  cacheCtx->sessionId = sessionId;
391  cacheCtx->session = nullptr;
392  cacheCtx->sslSocket = sslSocket;
393  cacheCtx->guard.reset(
394  new DelayedDestruction::DestructorGuard(cacheCtx->sslSocket));
395  cacheCtx->manager = this;
396  bool res = externalCache_->getAsync(sessionId, cacheCtx);
397  if (!res) {
398  delete cacheCtx;
399  }
400  return res;
401 }
std::shared_ptr< SSLCacheProvider > externalCache_
int wangle::SSLSessionCacheManager::newSession ( SSL *  ssl,
SSL_SESSION *  session 
)
private

Invoked by openssl when a new SSL session is created

Definition at line 207 of file SSLSessionCacheManager.cpp.

References externalCache_, wangle::SSLUtil::hexlify(), localCache_, wangle::SSLStats::recordSSLSession(), stats_, and storeCacheRecord().

Referenced by newSessionCallback().

207  {
208  unsigned int sessIdLen = 0;
209  const unsigned char* sessId = SSL_SESSION_get_id(session, &sessIdLen);
210  string sessionId((char*) sessId, sessIdLen);
211  VLOG(4) << "New SSL session; id=" << SSLUtil::hexlify(sessionId);
212 
213  if (stats_) {
214  stats_->recordSSLSession(true /* new session */, false, false);
215  }
216 
217  localCache_->storeSession(sessionId, session, stats_);
218 
219  if (externalCache_) {
220  VLOG(4) << "New SSL session: send session to external cache; id=" <<
221  SSLUtil::hexlify(sessionId);
222  storeCacheRecord(sessionId, session);
223  }
224 
225  return 1;
226 }
bool storeCacheRecord(const std::string &sessionId, SSL_SESSION *session)
virtual void recordSSLSession(bool sessionNew, bool sessionHit, bool foreign) noexcept=0
std::shared_ptr< ShardedLocalSSLSessionCache > localCache_
static std::string hexlify(const std::string &binary)
Definition: SSLUtil.h:150
std::shared_ptr< SSLCacheProvider > externalCache_
int wangle::SSLSessionCacheManager::newSessionCallback ( SSL *  ssl,
SSL_SESSION *  session 
)
staticprivate

static functions registered as callbacks to openssl via SSL_CTX_sess_set_new/get/remove_cb

Definition at line 195 of file SSLSessionCacheManager.cpp.

References folly::FATAL, newSession(), and sExDataIndex_.

Referenced by SSLSessionCacheManager().

195  {
196  SSLSessionCacheManager* manager = nullptr;
197  SSL_CTX* ctx = SSL_get_SSL_CTX(ssl);
198  manager = (SSLSessionCacheManager *)SSL_CTX_get_ex_data(ctx, sExDataIndex_);
199 
200  if (manager == nullptr) {
201  LOG(FATAL) << "Null SSLSessionCacheManager in callback";
202  }
203  return manager->newSession(ssl, session);
204 }
SSLSessionCacheManager(uint32_t maxCacheSize, uint32_t cacheCullSize, folly::SSLContext *ctx, const std::string &context, SSLStats *stats, const std::shared_ptr< SSLCacheProvider > &externalCache)
void wangle::SSLSessionCacheManager::onGetFailure ( SSLCacheProvider::CacheContext cacheCtx)

Callback for ExternalCache to call when an async get fails, either because the requested session is not in the external cache or because of an error.

Parameters
contextThe context that was passed to the async get request

Definition at line 450 of file SSLSessionCacheManager.cpp.

References restartSSLAccept().

451  {
452  restartSSLAccept(cacheCtx);
453  delete cacheCtx;
454 }
void restartSSLAccept(const SSLCacheProvider::CacheContext *cacheCtx)
void wangle::SSLSessionCacheManager::onGetSuccess ( SSLCacheProvider::CacheContext cacheCtx,
const std::string value 
)

Callback for ExternalCache to call when an async get succeeds

Parameters
contextThe context that was passed to the async get request
valueSerialized session

Definition at line 434 of file SSLSessionCacheManager.cpp.

References restoreSession(), and uint8_t.

436  {
437  restoreSession(cacheCtx, (uint8_t*)value.data(), value.length());
438 }
static const char *const value
Definition: Conv.cpp:50
void restoreSession(SSLCacheProvider::CacheContext *cacheCtx, const uint8_t *data, size_t length)
void wangle::SSLSessionCacheManager::onGetSuccess ( SSLCacheProvider::CacheContext cacheCtx,
std::unique_ptr< folly::IOBuf valueBuf 
)

Callback for ExternalCache to call when an async get succeeds

Parameters
contextThe context that was passed to the async get request
valueBufSerialized session stored in folly::IOBuf, this should NOT be called with valueBuf == nullptr.

Definition at line 440 of file SSLSessionCacheManager.cpp.

References folly::IOBuf::coalesce(), folly::IOBuf::data(), folly::IOBuf::length(), and restoreSession().

442  {
443  if (!valueBuf) {
444  return;
445  }
446  valueBuf->coalesce();
447  restoreSession(cacheCtx, valueBuf->data(), valueBuf->length());
448 }
ByteRange coalesce()
Definition: IOBuf.h:1095
const uint8_t * data() const
Definition: IOBuf.h:499
std::size_t length() const
Definition: IOBuf.h:533
void restoreSession(SSLCacheProvider::CacheContext *cacheCtx, const uint8_t *data, size_t length)
void wangle::SSLSessionCacheManager::removeSession ( SSL_CTX *  ctx,
SSL_SESSION *  session 
)
private

Invoked by openssl when an SSL session is ejected from its internal cache. This can't be invoked in the current implementation because SSL's internal caching is disabled.

Definition at line 239 of file SSLSessionCacheManager.cpp.

References wangle::SSLUtil::hexlify(), localCache_, wangle::SSLStats::recordSSLSessionRemove(), and stats_.

Referenced by removeSessionCallback().

240  {
241  unsigned int sessIdLen = 0;
242  const unsigned char* sessId = SSL_SESSION_get_id(session, &sessIdLen);
243  string sessionId((char*) sessId, sessIdLen);
244 
245  // This hook is only called from SSL when the internal session cache needs to
246  // flush sessions. Since we run with the internal cache disabled, this should
247  // never be called
248  VLOG(3) << "Remove SSL session; id=" << SSLUtil::hexlify(sessionId);
249 
250  localCache_->removeSession(sessionId);
251 
252  if (stats_) {
254  }
255 }
virtual void recordSSLSessionRemove() noexcept=0
std::shared_ptr< ShardedLocalSSLSessionCache > localCache_
static std::string hexlify(const std::string &binary)
Definition: SSLUtil.h:150
void wangle::SSLSessionCacheManager::removeSessionCallback ( SSL_CTX *  ctx,
SSL_SESSION *  session 
)
staticprivate

Definition at line 228 of file SSLSessionCacheManager.cpp.

References folly::FATAL, removeSession(), and sExDataIndex_.

Referenced by SSLSessionCacheManager().

229  {
230  SSLSessionCacheManager* manager = nullptr;
231  manager = (SSLSessionCacheManager *)SSL_CTX_get_ex_data(ctx, sExDataIndex_);
232 
233  if (manager == nullptr) {
234  LOG(FATAL) << "Null SSLSessionCacheManager in callback";
235  }
236  return manager->removeSession(ctx, session);
237 }
SSLSessionCacheManager(uint32_t maxCacheSize, uint32_t cacheCullSize, folly::SSLContext *ctx, const std::string &context, SSLStats *stats, const std::shared_ptr< SSLCacheProvider > &externalCache)
void wangle::SSLSessionCacheManager::restartSSLAccept ( const SSLCacheProvider::CacheContext cacheCtx)
private

Restart all clients waiting for the answer to an external cache query

Definition at line 403 of file SSLSessionCacheManager.cpp.

References pendingLookups_, folly::AsyncSSLSocket::restartSSLAccept(), wangle::SSLCacheProvider::CacheContext::session, wangle::SSLCacheProvider::CacheContext::sessionId, and wangle::SSLCacheProvider::CacheContext::sslSocket.

Referenced by onGetFailure(), and restoreSession().

404  {
405  PendingLookupMap::iterator pit = pendingLookups_.find(cacheCtx->sessionId);
406  CHECK(pit != pendingLookups_.end());
407  pit->second.request_in_progress = false;
408  pit->second.session = cacheCtx->session;
409  VLOG(7) << "Restart SSL accept";
410  cacheCtx->sslSocket->restartSSLAccept();
411  for (const auto& attachedLookup: pit->second.waiters) {
412  // Wake up anyone else who was waiting for this session
413  VLOG(4) << "Restart SSL accept (waiters) for fd=" <<
414  attachedLookup.first->getFd();
415  attachedLookup.first->restartSSLAccept();
416  }
417  pendingLookups_.erase(pit);
418 }
void wangle::SSLSessionCacheManager::restoreSession ( SSLCacheProvider::CacheContext cacheCtx,
const uint8_t data,
size_t  length 
)
private

Invoked by onGetSuccess callback, to restore session from cache.

Parameters
contextThe context that was passed to the async get request
dataBuffer that stores serialized session
lengthBuffer size

Definition at line 420 of file SSLSessionCacheManager.cpp.

References localCache_, restartSSLAccept(), wangle::SSLCacheProvider::CacheContext::session, wangle::SSLCacheProvider::CacheContext::sessionId, and stats_.

Referenced by onGetSuccess().

423  {
424  cacheCtx->session = d2i_SSL_SESSION(nullptr, &data, length);
425  restartSSLAccept(cacheCtx);
426 
427  /* Insert in the LRU after restarting all clients. The stats logic
428  * in getSession would treat this as a local hit otherwise.
429  */
430  localCache_->storeSession(cacheCtx->sessionId, cacheCtx->session, stats_);
431  delete cacheCtx;
432 }
void restartSSLAccept(const SSLCacheProvider::CacheContext *cacheCtx)
std::shared_ptr< ShardedLocalSSLSessionCache > localCache_
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
void wangle::SSLSessionCacheManager::shutdown ( )
static

Call this on shutdown to release the global instance of the ShardedLocalSSLSessionCache.

Definition at line 177 of file SSLSessionCacheManager.cpp.

References g(), sCache_, and sCacheLock_.

177  {
178  std::lock_guard<std::mutex> g(sCacheLock_);
179  sCache_.reset();
180 }
static std::shared_ptr< ShardedLocalSSLSessionCache > sCache_
g_t g(f_t)
bool wangle::SSLSessionCacheManager::storeCacheRecord ( const std::string sessionId,
SSL_SESSION *  session 
)
private

Store a new session record in the external cache

Definition at line 375 of file SSLSessionCacheManager.cpp.

References ctx_, expiration(), externalCache_, folly::SSLContext::getSSLCtx(), string, uint32_t, and uint8_t.

Referenced by newSession().

376  {
377  std::string sessionString;
378  uint32_t sessionLen = i2d_SSL_SESSION(session, nullptr);
379  sessionString.resize(sessionLen);
380  uint8_t* cp = (uint8_t *)sessionString.data();
381  i2d_SSL_SESSION(session, &cp);
382  size_t expiration = SSL_CTX_get_timeout(ctx_->getSSLCtx());
383  return externalCache_->setAsync(sessionId, sessionString,
384  std::chrono::seconds(expiration));
385 }
static void expiration()
SSL_CTX * getSSLCtx() const
Definition: SSLContext.h:503
const char * string
Definition: Conv.cpp:212
std::shared_ptr< SSLCacheProvider > externalCache_

Member Data Documentation

folly::SSLContext* wangle::SSLSessionCacheManager::ctx_
private

Definition at line 187 of file SSLSessionCacheManager.h.

Referenced by storeCacheRecord().

std::shared_ptr<SSLCacheProvider> wangle::SSLSessionCacheManager::externalCache_
private
std::shared_ptr<ShardedLocalSSLSessionCache> wangle::SSLSessionCacheManager::localCache_
private
PendingLookupMap wangle::SSLSessionCacheManager::pendingLookups_
private

Definition at line 189 of file SSLSessionCacheManager.h.

Referenced by getSession(), and restartSSLAccept().

shared_ptr< ShardedLocalSSLSessionCache > wangle::SSLSessionCacheManager::sCache_
staticprivate

Definition at line 265 of file SSLSessionCacheManager.h.

Referenced by getLocalCache(), and shutdown().

std::mutex wangle::SSLSessionCacheManager::sCacheLock_
staticprivate

Definition at line 266 of file SSLSessionCacheManager.h.

Referenced by getLocalCache(), and shutdown().

int wangle::SSLSessionCacheManager::sExDataIndex_ = -1
staticprivate
SSLStats* wangle::SSLSessionCacheManager::stats_ {nullptr}
private

Definition at line 190 of file SSLSessionCacheManager.h.

Referenced by getSession(), newSession(), removeSession(), and restoreSession().


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