aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2015-10-26 22:20:42 -0400
committerAlex Gaynor <alex.gaynor@gmail.com>2015-10-26 22:20:42 -0400
commit9c72a6bb3868979cf9416cfa526ea2fc066f854d (patch)
tree20d682a5ebab0be49800824d6b82e1e13e92b549 /src
parent9bbf778b7dde2fab6d957f3b5b4422d5bb3ce5a0 (diff)
parent1de222d8f35fcf56650fdfff0314566e24dcb055 (diff)
downloadcryptography-9c72a6bb3868979cf9416cfa526ea2fc066f854d.tar.gz
cryptography-9c72a6bb3868979cf9416cfa526ea2fc066f854d.tar.bz2
cryptography-9c72a6bb3868979cf9416cfa526ea2fc066f854d.zip
Merge pull request #2446 from reaperhulk/init-locks
move lock initialization to during binding import
Diffstat (limited to 'src')
-rw-r--r--src/cryptography/hazmat/backends/openssl/backend.py2
-rw-r--r--src/cryptography/hazmat/bindings/openssl/binding.py8
2 files changed, 8 insertions, 2 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py
index f7b5408a..6471da6e 100644
--- a/src/cryptography/hazmat/backends/openssl/backend.py
+++ b/src/cryptography/hazmat/backends/openssl/backend.py
@@ -614,8 +614,6 @@ class Backend(object):
res = self._lib.ASN1_STRING_set_default_mask_asc(b"utf8only")
self.openssl_assert(res == 1)
- self._binding.init_static_locks()
-
self._cipher_registry = {}
self._register_default_ciphers()
self.activate_osrandom_engine()
diff --git a/src/cryptography/hazmat/bindings/openssl/binding.py b/src/cryptography/hazmat/bindings/openssl/binding.py
index 4fac11d8..a750cd6b 100644
--- a/src/cryptography/hazmat/bindings/openssl/binding.py
+++ b/src/cryptography/hazmat/bindings/openssl/binding.py
@@ -172,3 +172,11 @@ class Binding(object):
mode, n, file, line
)
)
+
+
+# OpenSSL is not thread safe until the locks are initialized. We call this
+# method in module scope so that it executes with the import lock. On
+# Pythons < 3.4 this import lock is a global lock, which can prevent a race
+# condition registering the OpenSSL locks. On Python 3.4+ the import lock
+# is per module so this approach will not work.
+Binding.init_static_locks()