aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyph <glyph@twistedmatrix.com>2015-06-27 18:41:16 -0700
committerGlyph <glyph@twistedmatrix.com>2015-06-27 18:41:16 -0700
commit1e3ffe10719ef8eeeda0df79aa3e708400f7028a (patch)
treeb1653800ced15b9a6ff03520b0cf8b0bb8a1e99a
parenteb8059d7bd4abc11a14bdf149812057d505a2685 (diff)
downloadcryptography-1e3ffe10719ef8eeeda0df79aa3e708400f7028a.tar.gz
cryptography-1e3ffe10719ef8eeeda0df79aa3e708400f7028a.tar.bz2
cryptography-1e3ffe10719ef8eeeda0df79aa3e708400f7028a.zip
handle previous registration by raising RuntimeError
-rw-r--r--src/cryptography/hazmat/bindings/openssl/binding.py4
-rw-r--r--tests/hazmat/bindings/test_openssl.py4
2 files changed, 3 insertions, 5 deletions
diff --git a/src/cryptography/hazmat/bindings/openssl/binding.py b/src/cryptography/hazmat/bindings/openssl/binding.py
index 727522a3..be9904a2 100644
--- a/src/cryptography/hazmat/bindings/openssl/binding.py
+++ b/src/cryptography/hazmat/bindings/openssl/binding.py
@@ -46,8 +46,7 @@ def _register_osrandom_engine():
assert lib.ERR_peek_error() == 0
looked_up_engine = lib.ENGINE_by_id(_osrandom_engine_id)
if looked_up_engine != ffi.NULL:
- assert lib.ERR_peek_error() == 0
- return 2
+ raise RuntimeError("osrandom engine already registered")
lib.ERR_clear_error()
@@ -64,7 +63,6 @@ def _register_osrandom_engine():
finally:
result = lib.ENGINE_free(engine)
assert result == 1
- return 1
class Binding(object):
diff --git a/tests/hazmat/bindings/test_openssl.py b/tests/hazmat/bindings/test_openssl.py
index fe78b0ba..75a8e3f1 100644
--- a/tests/hazmat/bindings/test_openssl.py
+++ b/tests/hazmat/bindings/test_openssl.py
@@ -89,8 +89,8 @@ class TestOpenSSL(object):
def test_add_engine_more_than_once(self):
b = Binding()
- res = b._register_osrandom_engine()
- assert res == 2
+ with pytest.raises(RuntimeError):
+ b._register_osrandom_engine()
def test_ssl_ctx_options(self):
# Test that we're properly handling 32-bit unsigned on all platforms.