From 6adb9319368235daf31e5b72ddfc2b7265abc1c5 Mon Sep 17 00:00:00 2001 From: Cedric Caffy Date: Wed, 21 Dec 2022 11:00:24 +0100 Subject: [PATCH] XrdTlsContext: Recreate session cache in the Clone() method This fixes the issue #1874 --- src/XrdTls/XrdTlsContext.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/XrdTls/XrdTlsContext.cc b/src/XrdTls/XrdTlsContext.cc index 2dfd12b06d2..d31ae3d6709 100644 --- a/src/XrdTls/XrdTlsContext.cc +++ b/src/XrdTls/XrdTlsContext.cc @@ -72,6 +72,8 @@ struct XrdTlsContextImpl bool crlRunning; bool flsRunning; time_t lastCertModTime = 0; + int sessionCacheOpts = -1; + std::string sessionCacheId; }; /******************************************************************************/ @@ -779,7 +781,13 @@ XrdTlsContext *XrdTlsContext::Clone(bool full,bool startCRLRefresh) // Verify that the context was built // - if (xtc->isOK()) return xtc; + if (xtc->isOK()) { + if(pImpl->sessionCacheOpts != -1){ + //A SessionCache() call was done for the current context, so apply it for this new cloned context + xtc->SessionCache(pImpl->sessionCacheOpts,pImpl->sessionCacheId.c_str(),pImpl->sessionCacheId.size()); + } + return xtc; + } // We failed, cleanup. // @@ -940,6 +948,9 @@ int XrdTlsContext::SessionCache(int opts, const char *id, int idlen) long sslopt = 0; int flushT = opts & scFMax; + pImpl->sessionCacheOpts = opts; + pImpl->sessionCacheId = id; + // If initialization failed there is nothing to do // if (pImpl->ctx == 0) return 0;