summaryrefslogtreecommitdiffstats
path: root/base/common/python/pki/systemcert.py
diff options
context:
space:
mode:
authorChristian Heimes <cheimes@redhat.com>2015-09-21 14:44:50 +0200
committerChristian Heimes <cheimes@redhat.com>2015-10-01 20:02:59 +0200
commit344caf335d94e7aa3a32bdd850ed1363088c896d (patch)
tree25407b09ad8a79e59f0446c47d3debc9b3adddfa /base/common/python/pki/systemcert.py
parent4f5051463ea9dc1366a2b58b9814c0e7997c1813 (diff)
downloadpki-344caf335d94e7aa3a32bdd850ed1363088c896d.tar.gz
pki-344caf335d94e7aa3a32bdd850ed1363088c896d.tar.xz
pki-344caf335d94e7aa3a32bdd850ed1363088c896d.zip
Replace legacy Python base64 invocations with Py3-safe code
Replace deprecated decodestring() and encodestring() with b64decode() and b64encode(). Provice specialized encode_cert() / decode_cert() functions to handle base64 encoding and decoding for X.509 certs in JSON strings. In Python 3 the base64 function don't suppor ASCII text, just ASCII bytes.
Diffstat (limited to 'base/common/python/pki/systemcert.py')
-rw-r--r--base/common/python/pki/systemcert.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/base/common/python/pki/systemcert.py b/base/common/python/pki/systemcert.py
index 4adc2f18e..199838b9e 100644
--- a/base/common/python/pki/systemcert.py
+++ b/base/common/python/pki/systemcert.py
@@ -22,9 +22,10 @@
Module containing the Python client classes for the SystemCert REST API
"""
from __future__ import absolute_import
-import base64
+
import pki
from pki.cert import CertData
+from pki.encoder import decode_cert
class SystemCertClient(object):
@@ -55,6 +56,6 @@ class SystemCertClient(object):
pem = cert_data.encoded
b64 = pem[len(pki.CERT_HEADER):len(pem) - len(pki.CERT_FOOTER)]
- cert_data.binary = base64.decodestring(b64)
+ cert_data.binary = decode_cert(b64)
return cert_data