Skip to content

Commit eb3faf8

Browse files
committed
crypto._cert_fingerprint: pass bytes to load_pem_x509_certificate
crypto._cert_fingerprint must ensure first parameter to load_pem_x509_certificate is bytes, as there are code paths which pass this as a string, such as crypto.from_keyspec -> crypto._load_keyspec -> crypto.XMLSecCryptoFromXML.__init__ -> crypto._cert_fingerprint
1 parent 739191d commit eb3faf8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Diff for: src/xmlsec/crypto.py

+2
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ def _get_cert_by_fp(self, fp):
358358

359359
def _cert_fingerprint(cert_pem):
360360
if "-----BEGIN CERTIFICATE" in cert_pem:
361+
if isinstance(cert_pem, six.text_type):
362+
cert_pem = cert_pem.encode()
361363
cert = load_pem_x509_certificate(cert_pem, backend=default_backend())
362364
else:
363365
cert = load_der_x509_certificate(base64.standard_b64decode(cert_pem), backend=default_backend())

0 commit comments

Comments
 (0)