aboutsummaryrefslogtreecommitdiffstats
path: root/src/cryptography/hazmat/bindings/openssl/binding.py
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2015-08-29 18:18:53 -0500
committerPaul Kehrer <paul.l.kehrer@gmail.com>2015-08-29 20:05:34 -0500
commit89656cd08cf0369677b298f30ba754cb62e5009b (patch)
tree64b7c97a9ddd324689eb67242a05382ba0729ab2 /src/cryptography/hazmat/bindings/openssl/binding.py
parentb2ecff2447e06c9cd5747228cb5bbf9d44bbcdfe (diff)
downloadcryptography-89656cd08cf0369677b298f30ba754cb62e5009b.tar.gz
cryptography-89656cd08cf0369677b298f30ba754cb62e5009b.tar.bz2
cryptography-89656cd08cf0369677b298f30ba754cb62e5009b.zip
Resolve an unusual test bug related to initializing the bindings
To make calls against the "SSL" parts of OpenSSL you need to call SSL_library_init. There are multiple ways this can be called: * If you're using the same OpenSSL in cryptography as you are in your Python then Python will call it for you. * If you import the openssl backend. These tests need SSL_library_init to be called. When run in our CI SSL_library_init is called because during the parametrization step the OpenSSL backend is imported (thus triggering it). However, you can also run tests directly via py.test and without this change py.test tests/hazmat/bindings/test_openssl.py would crash if you had cryptography linked against a different OpenSSL than your Python used.
Diffstat (limited to 'src/cryptography/hazmat/bindings/openssl/binding.py')
-rw-r--r--src/cryptography/hazmat/bindings/openssl/binding.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cryptography/hazmat/bindings/openssl/binding.py b/src/cryptography/hazmat/bindings/openssl/binding.py
index e18d89c5..50d7f6d5 100644
--- a/src/cryptography/hazmat/bindings/openssl/binding.py
+++ b/src/cryptography/hazmat/bindings/openssl/binding.py
@@ -92,6 +92,12 @@ class Binding(object):
if not cls._lib_loaded:
cls.lib = build_conditional_library(lib, CONDITIONAL_NAMES)
cls._lib_loaded = True
+ # initialize the SSL library
+ cls.lib.SSL_library_init()
+ # adds all ciphers/digests for EVP
+ cls.lib.OpenSSL_add_all_algorithms()
+ # loads error strings for libcrypto and libssl functions
+ cls.lib.SSL_load_error_strings()
cls._register_osrandom_engine()
@classmethod