diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2016-03-09 07:07:52 -0500 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2016-03-09 07:07:52 -0500 |
| commit | 9e753d4bfd187568c99dce5de6c2bc034aae717e (patch) | |
| tree | 82825f95746f1ebf5e7c545ec4a6c5442d4bb588 /src | |
| parent | 7830dd2111ac968f039660dd077e9c43a0f32c56 (diff) | |
| parent | 1783335b8fb5dc7be3a1214ff4825eaec318b12a (diff) | |
| download | cryptography-9e753d4bfd187568c99dce5de6c2bc034aae717e.tar.gz cryptography-9e753d4bfd187568c99dce5de6c2bc034aae717e.tar.bz2 cryptography-9e753d4bfd187568c99dce5de6c2bc034aae717e.zip | |
Merge pull request #2774 from reaperhulk/improve-unknown-error
improve the messages from openssl InternalError
Diffstat (limited to 'src')
| -rw-r--r-- | src/cryptography/hazmat/bindings/openssl/binding.py | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/cryptography/hazmat/bindings/openssl/binding.py b/src/cryptography/hazmat/bindings/openssl/binding.py index b2215de3..5d7466f9 100644 --- a/src/cryptography/hazmat/bindings/openssl/binding.py +++ b/src/cryptography/hazmat/bindings/openssl/binding.py @@ -17,6 +17,9 @@ 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"] +) def _consume_errors(lib): @@ -31,17 +34,33 @@ def _consume_errors(lib): err_reason = lib.ERR_GET_REASON(code) errors.append(_OpenSSLError(code, err_lib, err_func, err_reason)) + return errors def _openssl_assert(lib, ok): if not ok: errors = _consume_errors(lib) + errors_with_text = [] + for err in errors: + err_text_reason = ffi.string( + lib.ERR_error_string(err.code, ffi.NULL) + ) + errors_with_text.append( + _OpenSSLErrorWithText( + err.code, err.lib, err.func, err.reason, err_text_reason + ) + ) + raise InternalError( - "Unknown OpenSSL error. Please file an issue at https://github.com" - "/pyca/cryptography/issues with information on how to reproduce " - "this. ({0!r})".format(errors), - errors + "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 library that uses " + "OpenSSL try disabling it before reporting a bug. Otherwise " + "please file an issue at https://github.com/pyca/cryptography/" + "issues with information on how to reproduce " + "this. ({0!r})".format(errors_with_text), + errors_with_text ) |
