Fix issue when a cert doesn't have any SANs

This commit is contained in:
Benjamin Collet 2025-01-07 16:33:40 +01:00
parent 6c02075a57
commit b6cbbe6ca3
Signed by: bcollet
SSH key fingerprint: SHA256:8UJspOIcCOS+MtSOcnuq2HjKFube4ox1s/+A62ixov4

View file

@ -59,8 +59,12 @@ class cert:
self.subject = cert.subject.rfc4514_string({x509.NameOID.EMAIL_ADDRESS: "E"}) self.subject = cert.subject.rfc4514_string({x509.NameOID.EMAIL_ADDRESS: "E"})
self.not_before = cert.not_valid_before_utc.replace(microsecond=0) self.not_before = cert.not_valid_before_utc.replace(microsecond=0)
self.not_after = cert.not_valid_after_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) try:
self.san_names = san_data.value.get_values_for_type(x509.GeneralName) 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) self.provisioner = cert_data.get("provisioner", None)
if cert_revoked is not None: if cert_revoked is not None: