aboutsummaryrefslogtreecommitdiffstats
path: root/src/cryptography/hazmat/bindings
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2017-05-25 23:05:00 -0500
committerAlex Gaynor <alex.gaynor@gmail.com>2017-05-26 00:05:00 -0400
commitd36bef0b744d79b209b13f87fb9c943e4091a2c5 (patch)
treeab33864d222f62b8c38511315e753063016c3153 /src/cryptography/hazmat/bindings
parent349923379f1c1baf51ff1709abaa19559a59ad69 (diff)
downloadcryptography-d36bef0b744d79b209b13f87fb9c943e4091a2c5.tar.gz
cryptography-d36bef0b744d79b209b13f87fb9c943e4091a2c5.tar.bz2
cryptography-d36bef0b744d79b209b13f87fb9c943e4091a2c5.zip
fix libressl error/refactor some error handling (#3609)
* add libre so I can see the error * add the libre error needed and refactor error handling a bit We were historically matching on lib + func + reason, but func is somewhat unstable so now we match on lib + reason only. Of course, in this case libressl changed both lib and reason so it wouldn't have mattered. All error handling from the error queue in openssl is an illusion * fix a typo, probably an unneeded branch * review feedback * refactor tests to support libressl insert additional rant about libre here, although admittedly these tests were assuming stability where openssl itself guarantees none * better assert, fix flake8
Diffstat (limited to 'src/cryptography/hazmat/bindings')
-rw-r--r--src/cryptography/hazmat/bindings/openssl/binding.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/cryptography/hazmat/bindings/openssl/binding.py b/src/cryptography/hazmat/bindings/openssl/binding.py
index 6b3d50c4..d00fc794 100644
--- a/src/cryptography/hazmat/bindings/openssl/binding.py
+++ b/src/cryptography/hazmat/bindings/openssl/binding.py
@@ -8,17 +8,32 @@ import collections
import threading
import types
+from cryptography import utils
from cryptography.exceptions import InternalError
from cryptography.hazmat.bindings._openssl import ffi, lib
from cryptography.hazmat.bindings.openssl._conditional import CONDITIONAL_NAMES
-_OpenSSLError = collections.namedtuple("_OpenSSLError",
- ["code", "lib", "func", "reason"])
_OpenSSLErrorWithText = collections.namedtuple(
"_OpenSSLErrorWithText", ["code", "lib", "func", "reason", "reason_text"]
)
+class _OpenSSLError(object):
+ def __init__(self, code, lib, func, reason):
+ self._code = code
+ self._lib = lib
+ self._func = func
+ self._reason = reason
+
+ def _lib_reason_match(self, lib, reason):
+ return lib == self.lib and reason == self.reason
+
+ code = utils.read_only_property("_code")
+ lib = utils.read_only_property("_lib")
+ func = utils.read_only_property("_func")
+ reason = utils.read_only_property("_reason")
+
+
def _consume_errors(lib):
errors = []
while True: