Add static method to skip SSL init
authorJoel Goguen <jgoguen@fb.com>
Thu, 2 Apr 2015 23:37:50 +0000 (16:37 -0700)
committerViswanath Sivakumar <viswanath@fb.com>
Fri, 10 Apr 2015 03:33:34 +0000 (20:33 -0700)
Summary:
Some things like gSOAP, initialize SSL only to have SSLContext stomp over their
work. Add a method to allow flagging SSLContext as "initialized" to use the
existing global state.

Test Plan:
Tested running mcrouter and paymentnegined to verify existing
functionality appears normal.

Reviewed By: subodh@fb.com

Subscribers: ssl-diffs@, folly-diffs@, yfeldblum, chalfant, dihde

FB internal diff: D1959936

Tasks: 6655251

Signature: t1:1959936:1427994292:8b2be1742ef17a5ec2c7b3ad37787d2cf4d142a6

folly/io/async/SSLContext.cpp
folly/io/async/SSLContext.h

index c05fe330f9a0a95c8f264950cb712e987c8f371e..38dddf971a31d880d59a20e967be6b3093a9d4ef 100644 (file)
@@ -682,6 +682,11 @@ void SSLContext::setSSLLockTypes(std::map<int, SSLLockType> inLockTypes) {
   lockTypes() = inLockTypes;
 }
 
+void SSLContext::markInitialized() {
+  std::lock_guard<std::mutex> g(mutex_);
+  initialized_ = true;
+}
+
 void SSLContext::initializeOpenSSL() {
   std::lock_guard<std::mutex> g(mutex_);
   initializeOpenSSLLocked();
index 6947ac7f739dd5180fc80df80e3ddddddfb7c14f..7101b561592d4861a1986bc215f9db60ca678bfe 100644 (file)
@@ -403,6 +403,13 @@ class SSLContext {
   static void initializeOpenSSL();
   static void cleanupOpenSSL();
 
+  /**
+   * Mark openssl as initialized without actually performing any initialization.
+   * Please use this only if you are using a library which requires that it must
+   * make its own calls to SSL_library_init() and related functions.
+   */
+  static void markInitialized();
+
   /**
    * Default randomize method.
    */