Ignore setSSLLockTypes() calls after SSLContext is initialized. v2017.04.24.00
authorNeel Goyal <ngoyal@fb.com>
Sat, 22 Apr 2017 16:18:55 +0000 (09:18 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Sat, 22 Apr 2017 16:25:36 +0000 (09:25 -0700)
Summary: We set the actual locks on initialization, so attempting to change locks after had no affect, other than making isSSLLockDisabled() report incorrect information.

Reviewed By: yfeldblum

Differential Revision: D4935475

fbshipit-source-id: 7b80cd530801c925ade769163579b86b1a8f0027

folly/io/async/SSLContext.cpp
folly/io/async/test/AsyncSSLSocketTest2.cpp

index 5550cdbb96ffa3200f81dbdd40ea2a0dd1189be3..3abb5d0b8a307439a2ec09d3a7c19ac32f014c06 100644 (file)
@@ -794,6 +794,13 @@ static void dyn_destroy(struct CRYPTO_dynlock_value* lock, const char*, int) {
 }
 
 void SSLContext::setSSLLockTypes(std::map<int, SSLLockType> inLockTypes) {
+  if (initialized_) {
+    // We set the locks on initialization, so if we are already initialized
+    // this would have no affect.
+    LOG(INFO) << "Ignoring setSSLLockTypes after initialization";
+    return;
+  }
+
   lockTypes() = inLockTypes;
 }
 
index bd85d533706d949a6330c2c79556cfe96499d2aa..54454c9fbbaf75a7eb376926608e7485c955fde7 100644 (file)
@@ -205,6 +205,14 @@ TEST(AsyncSSLSocketTest2, SSLContextLocks) {
 #endif
 }
 
+TEST(AsyncSSLSocketTest2, SSLContextLocksSetAfterInitIgnored) {
+  SSLContext::initializeOpenSSL();
+  SSLContext::setSSLLockTypes({});
+#ifdef CRYPTO_LOCK_EVP_PKEY
+  EXPECT_TRUE(SSLContext::isSSLLockDisabled(CRYPTO_LOCK_EVP_PKEY));
+#endif
+}
+
 }  // folly
 
 int main(int argc, char *argv[]) {