diff options
author | Martin Basti <mbasti@redhat.com> | 2017-01-24 17:49:06 +0100 |
---|---|---|
committer | Jan Cholasta <jcholast@redhat.com> | 2017-02-08 08:32:44 +0100 |
commit | caa560ca79e4038b161b27d11e3f144606dbbcdb (patch) | |
tree | d3b4b053061170ffa182be3f1e012e56899eac78 /ipaserver/plugins | |
parent | 8e139d4b559a6f19d859e078e1940a69d8977fdb (diff) | |
download | freeipa-caa560ca79e4038b161b27d11e3f144606dbbcdb.tar.gz freeipa-caa560ca79e4038b161b27d11e3f144606dbbcdb.tar.xz freeipa-caa560ca79e4038b161b27d11e3f144606dbbcdb.zip |
py3: base64 encoding/decoding returns always bytes don't mix it
Using unicode(bytes) call causes undesired side effect that is inserting
`b` character to result. This obviously causes issues with binary base64 data
https://fedorahosted.org/freeipa/ticket/4985
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipaserver/plugins')
-rw-r--r-- | ipaserver/plugins/baseldap.py | 2 | ||||
-rw-r--r-- | ipaserver/plugins/ca.py | 4 | ||||
-rw-r--r-- | ipaserver/plugins/cert.py | 2 |
3 files changed, 3 insertions, 5 deletions
diff --git a/ipaserver/plugins/baseldap.py b/ipaserver/plugins/baseldap.py index e7bf43cad..24b6db7c0 100644 --- a/ipaserver/plugins/baseldap.py +++ b/ipaserver/plugins/baseldap.py @@ -1036,7 +1036,7 @@ last, after all sets and adds."""), except ValueError: if isinstance(delval, bytes): # This is a Binary value, base64 encode it - delval = unicode(base64.b64encode(delval)) + delval = base64.b64encode(delval).decode('ascii') raise errors.AttrValueNotFound(attr=attr, value=delval) # normalize all values diff --git a/ipaserver/plugins/ca.py b/ipaserver/plugins/ca.py index 4f24278b3..3a052a117 100644 --- a/ipaserver/plugins/ca.py +++ b/ipaserver/plugins/ca.py @@ -4,8 +4,6 @@ import base64 -import six - from ipalib import api, errors, output, Bytes, DNParam, Flag, Str from ipalib.constants import IPA_CA_CN from ipalib.plugable import Registry @@ -176,7 +174,7 @@ def set_certificate_attrs(entry, options, want_cert=True): with api.Backend.ra_lightweight_ca as ca_api: if want_cert or full: der = ca_api.read_ca_cert(ca_id) - entry['certificate'] = six.text_type(base64.b64encode(der)) + entry['certificate'] = base64.b64encode(der).decode('ascii') if want_chain or full: pkcs7_der = ca_api.read_ca_chain(ca_id) diff --git a/ipaserver/plugins/cert.py b/ipaserver/plugins/cert.py index 5bf4cfba3..6bf5c03ef 100644 --- a/ipaserver/plugins/cert.py +++ b/ipaserver/plugins/cert.py @@ -1260,7 +1260,7 @@ class cert_find(Search, CertMethod): return (DN(cert_obj.issuer), cert_obj.serial) def _get_cert_obj(self, cert, all, raw, pkey_only): - obj = {'certificate': unicode(base64.b64encode(cert))} + obj = {'certificate': base64.b64encode(cert).decode('ascii')} full = not pkey_only and all if not raw: |