Fixed #322 -- removed code that already exists in cryptography
diff --git a/OpenSSL/crypto.py b/OpenSSL/crypto.py
index a52862c..92ec815 100644
--- a/OpenSSL/crypto.py
+++ b/OpenSSL/crypto.py
@@ -10,6 +10,7 @@
PY3 as _PY3)
from OpenSSL._util import (
+ binding as _binding,
ffi as _ffi,
lib as _lib,
exception_from_error_queue as _exception_from_error_queue,
@@ -2808,34 +2809,7 @@
return pkcs12
-def _initialize_openssl_threads(get_ident, Lock):
- import _ssl
- return
-
- locks = list(Lock() for n in range(_lib.CRYPTO_num_locks()))
-
- def locking_function(mode, index, filename, line):
- if mode & _lib.CRYPTO_LOCK:
- locks[index].acquire()
- else:
- locks[index].release()
-
- _lib.CRYPTO_set_id_callback(
- _ffi.callback("unsigned long (*)(void)", get_ident))
-
- _lib.CRYPTO_set_locking_callback(
- _ffi.callback(
- "void (*)(int, int, const char*, int)", locking_function))
-
-
-try:
- from thread import get_ident
- from threading import Lock
-except ImportError:
- pass
-else:
- _initialize_openssl_threads(get_ident, Lock)
- del get_ident, Lock
+_binding.init_static_locks()
# There are no direct unit tests for this initialization. It is tested
# indirectly since it is necessary for functions like dump_privatekey when