diff options
| author | Alex Stapleton <alexs@prol.etari.at> | 2014-02-02 11:00:36 +0000 |
|---|---|---|
| committer | Alex Stapleton <alexs@prol.etari.at> | 2014-02-02 15:58:27 +0000 |
| commit | 30ff19b11a5586679549fbff8bddc0c03d4c590f (patch) | |
| tree | 1a9f5d1feedfcc3b3fb2ffd15c92b8534f5241a2 /cryptography | |
| parent | b84b215af8e7669d50b7b63fb37e6854ba6f99db (diff) | |
| download | cryptography-30ff19b11a5586679549fbff8bddc0c03d4c590f.tar.gz cryptography-30ff19b11a5586679549fbff8bddc0c03d4c590f.tar.bz2 cryptography-30ff19b11a5586679549fbff8bddc0c03d4c590f.zip | |
More detailed error message for InternalError
Uses ERR_error_string_n because the source contains horrible warnings
against ever using ERR_error_string.
Diffstat (limited to 'cryptography')
| -rw-r--r-- | cryptography/hazmat/backends/openssl/backend.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py index e842f078..67b365fa 100644 --- a/cryptography/hazmat/backends/openssl/backend.py +++ b/cryptography/hazmat/backends/openssl/backend.py @@ -177,6 +177,11 @@ class Backend(object): return self._ffi.buffer(buf)[:] + def _err_string(self, code): + err_buf = self._ffi.new("char[]", 256) + self._lib.ERR_error_string_n(code, err_buf, 256) + return self._ffi.string(err_buf, 256)[:] + def _handle_error(self, mode): code = self._lib.ERR_get_error() if not code and isinstance(mode, GCM): @@ -211,7 +216,10 @@ class Backend(object): ) raise InternalError( - "Unknown error code from OpenSSL, you should probably file a bug." + "Unknown error code {0} from OpenSSL, " + "you should probably file a bug. {1}".format( + code, self._err_string(code) + ) ) |
