From 53f87ee5cd9d19f6fb91a9a1eafc8ea798095954 Mon Sep 17 00:00:00 2001 From: Fraser Tweedale Date: Mon, 16 Apr 2018 15:06:16 +1000 Subject: [PATCH] py3: fix csrgen error handling csrgen error handling marshalls an error string from libcrypto. This is not handled correctly under python3. Fix the error handling. Part of: https://pagure.io/freeipa/issue/7496 Reviewed-By: Christian Heimes --- ipaclient/csrgen_ffi.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ipaclient/csrgen_ffi.py b/ipaclient/csrgen_ffi.py index f1c1c7821..f185ddfba 100644 --- a/ipaclient/csrgen_ffi.py +++ b/ipaclient/csrgen_ffi.py @@ -182,8 +182,12 @@ def _raise_openssl_errors(): code = ERR_get_error() while code != 0: - msg = ERR_error_string(code, NULL) - msgs.append(_ffi.string(msg)) + msg = _ffi.string(ERR_error_string(code, NULL)) + try: + strmsg = msg.decode('utf-8') + except UnicodeDecodeError: + strmsg = repr(msg) + msgs.append(strmsg) code = ERR_get_error() raise errors.CSRTemplateError(reason='\n'.join(msgs))