From 5c21a8d01d3041382df94145524879a7d6d96a7c Mon Sep 17 00:00:00 2001 From: Stanislav Laznicka Date: Sep 15 2017 13:31:28 +0000 Subject: certmap testing: fix wrong cert construction `bytes` instances have no `.format()`, we can simply base64 decode the certificate and load it as DER instead. https://pagure.io/freeipa/issue/7131 Reviewed-By: Florence Blanc-Renaud Reviewed-By: Alexander Bokovoy --- diff --git a/ipatests/test_xmlrpc/tracker/certmapdata.py b/ipatests/test_xmlrpc/tracker/certmapdata.py index b869640..47db97e 100644 --- a/ipatests/test_xmlrpc/tracker/certmapdata.py +++ b/ipatests/test_xmlrpc/tracker/certmapdata.py @@ -1,6 +1,8 @@ # # Copyright (C) 2015 FreeIPA Contributors see COPYING for license # +import base64 + from cryptography import x509 from cryptography.hazmat.backends import default_backend from nose.tools import assert_raises @@ -50,11 +52,9 @@ class CertmapdataMixin(object): certs = [certs] for cert in certs: - cert = x509.load_pem_x509_certificate( - (b'-----BEGIN CERTIFICATE-----\n' - b'{}-----END CERTIFICATE-----\n' - .format(cert)), - default_backend() + cert = x509.load_der_x509_certificate( + base64.b64decode(cert), + backend=default_backend() ) issuer = DN(cert.issuer).x500_text() subject = DN(cert.subject).x500_text()