From c1d04467fdc58e4f97e7768f77706ac4c8099c42 Mon Sep 17 00:00:00 2001 From: Glyph Date: Sat, 27 Jun 2015 15:41:08 -0700 Subject: clear the error queue make sure we're not in an error state when we start, because then all bets are off and we might consume an error we didn't cause. then clear the error queue, which restores the behavior of the way the C module was previously checking for existence of its engine. --- src/cryptography/hazmat/bindings/openssl/binding.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/cryptography/hazmat/bindings/openssl/binding.py b/src/cryptography/hazmat/bindings/openssl/binding.py index d3999959..1fb7478d 100644 --- a/src/cryptography/hazmat/bindings/openssl/binding.py +++ b/src/cryptography/hazmat/bindings/openssl/binding.py @@ -42,10 +42,14 @@ method = ffi.new( 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 + lib.ERR_clear_error() + engine = lib.ENGINE_new() try: result = lib.ENGINE_set_id(engine, _osrandom_engine_id) -- cgit v1.2.3