Add getSSLContext() to AsyncSSLSocket
authorMingtao Yang <mingtao@fb.com>
Thu, 17 Aug 2017 20:54:11 +0000 (13:54 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 17 Aug 2017 21:04:38 +0000 (14:04 -0700)
Reviewed By: knekritz

Differential Revision: D5632201

fbshipit-source-id: 5db380379ab6cb608922c77dd716bfc4410b2cd8

folly/io/async/AsyncSSLSocket.h

index 84551d77dea5b98f648962044b62eca9c8764ef8..874fb9ddc6d32178774df675658f505ea7c8550c 100644 (file)
@@ -557,6 +557,18 @@ class AsyncSSLSocket : public virtual AsyncSocket {
   void detachSSLContext();
 #endif
 
   void detachSSLContext();
 #endif
 
+  /**
+   * Returns the original folly::SSLContext associated with this socket.
+   *
+   * Suitable for use in AsyncSSLSocket constructor to construct a new
+   * AsyncSSLSocket using an existing socket's context.
+   *
+   * switchServerSSLContext() does not affect this return value.
+   */
+  const std::shared_ptr<folly::SSLContext>& getSSLContext() const {
+    return ctx_;
+  }
+
 #if FOLLY_OPENSSL_HAS_SNI
   /**
    * Switch the SSLContext to continue the SSL handshake.
 #if FOLLY_OPENSSL_HAS_SNI
   /**
    * Switch the SSLContext to continue the SSL handshake.