ipalib.x809: Accept bytes for make_pem

Part of the work for https://fedorahosted.org/freeipa/ticket/5638

Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
Petr Viktorin
2016-02-19 17:51:27 +01:00
committed by Jan Cholasta
parent 272ff9d1f7
commit 34db5759fa

View File

@@ -272,6 +272,8 @@ def make_pem(data):
Convert a raw base64-encoded blob into something that looks like a PE
file with lines split to 64 characters and proper headers.
"""
if isinstance(data, bytes):
data = data.decode('ascii')
pemcert = '\r\n'.join([data[x:x+64] for x in range(0, len(data), 64)])
return '-----BEGIN CERTIFICATE-----\n' + \
pemcert + \