From 29591b4c9bf4cdc61172903fde6e5325f3be13f4 Mon Sep 17 00:00:00 2001 From: Wassilios Lytras Date: Mon, 10 Jan 2022 08:48:06 +0100 Subject: [PATCH] Handle the case where non utf-8 characters are present in the certificate subject --- pyas2lib/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyas2lib/utils.py b/pyas2lib/utils.py index ff204cc..5947c55 100644 --- a/pyas2lib/utils.py +++ b/pyas2lib/utils.py @@ -245,11 +245,11 @@ def extract_certificate_info(cert: bytes): certificate.get_notAfter().decode("utf8"), "%Y%m%d%H%M%SZ" ).replace(tzinfo=timezone.utc) cert_info["subject"] = [ - tuple(item.decode("utf8") for item in sets) + tuple(item.decode("utf8", "backslashreplace") for item in sets) for sets in certificate.get_subject().get_components() ] cert_info["issuer"] = [ - tuple(item.decode("utf8") for item in sets) + tuple(item.decode("utf8", "backslashreplace") for item in sets) for sets in certificate.get_issuer().get_components() ] cert_info["serial"] = certificate.get_serial_number()