From b6cbbe6ca36c10b09166a6e82e9ba330e4891bcb Mon Sep 17 00:00:00 2001 From: Benjamin Collet Date: Tue, 7 Jan 2025 16:33:40 +0100 Subject: [PATCH] Fix issue when a cert doesn't have any SANs --- models/x509_cert.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/models/x509_cert.py b/models/x509_cert.py index f9872af..19ce241 100644 --- a/models/x509_cert.py +++ b/models/x509_cert.py @@ -59,8 +59,12 @@ class cert: self.subject = cert.subject.rfc4514_string({x509.NameOID.EMAIL_ADDRESS: "E"}) self.not_before = cert.not_valid_before_utc.replace(microsecond=0) self.not_after = cert.not_valid_after_utc.replace(microsecond=0) - san_data = cert.extensions.get_extension_for_class(x509.SubjectAlternativeName) - self.san_names = san_data.value.get_values_for_type(x509.GeneralName) + try: + san_data = cert.extensions.get_extension_for_class(x509.SubjectAlternativeName) + self.san_names = san_data.value.get_values_for_type(x509.GeneralName) + except x509.extensions.ExtensionNotFound: + self.san_names = [] + self.provisioner = cert_data.get("provisioner", None) if cert_revoked is not None: