aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cryptography/hazmat/bindings/openssl/binding.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/cryptography/hazmat/bindings/openssl/binding.py b/src/cryptography/hazmat/bindings/openssl/binding.py
index b2215de3..d8fd74db 100644
--- a/src/cryptography/hazmat/bindings/openssl/binding.py
+++ b/src/cryptography/hazmat/bindings/openssl/binding.py
@@ -15,8 +15,9 @@ 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"])
+_OpenSSLError = collections.namedtuple(
+ "_OpenSSLError", ["code", "lib", "func", "reason", "reason_text"]
+)
def _consume_errors(lib):
@@ -29,8 +30,12 @@ def _consume_errors(lib):
err_lib = lib.ERR_GET_LIB(code)
err_func = lib.ERR_GET_FUNC(code)
err_reason = lib.ERR_GET_REASON(code)
+ err_text_reason = ffi.string(lib.ERR_error_string(code, ffi.NULL))
+
+ errors.append(
+ _OpenSSLError(code, err_lib, err_func, err_reason, err_text_reason)
+ )
- errors.append(_OpenSSLError(code, err_lib, err_func, err_reason))
return errors
@@ -38,8 +43,12 @@ def _openssl_assert(lib, ok):
if not ok:
errors = _consume_errors(lib)
raise InternalError(
- "Unknown OpenSSL error. Please file an issue at https://github.com"
- "/pyca/cryptography/issues with information on how to reproduce "
+ "Unknown OpenSSL error. This error is commonly encountered when "
+ "another library is not cleaning up the OpenSSL error stack. If "
+ "you are using cryptography with another Python library that "
+ "uses OpenSSL try disabling it before reporting a bug. Otherwise "
+ "iplease file an issue at https://github.com/pyca/cryptography/"
+ "issues with information on how to reproduce "
"this. ({0!r})".format(errors),
errors
)