mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-05-13 13:02:00 +00:00
Properly handle base64 enconding of certificates stored as bytes.
This change is needed to properly handle base64 encoding of certificates stored as bytes, under Python 3, as used by IPA service. It does not affect Python 2.7 as bytes are identical to str in this version of the language. When retireving certificates stored by FreeIPA service data is returned as bytes, under Python 3, and encoding then breaks, as there is no bytes.public_bytes method. In Python 3, encoding with base64 will be the same for strings and bytes.
This commit is contained in:
@@ -268,7 +268,7 @@ def encode_certificate(cert):
|
||||
Encode a certificate using base64 with also taking FreeIPA and Python
|
||||
versions into account
|
||||
"""
|
||||
if isinstance(cert, str) or isinstance(cert, unicode):
|
||||
if isinstance(cert, (str, unicode, bytes)):
|
||||
encoded = base64.b64encode(cert)
|
||||
else:
|
||||
encoded = base64.b64encode(cert.public_bytes(Encoding.DER))
|
||||
|
||||
Reference in New Issue
Block a user