fix: use compat getattr for not_valid_after/before_utc to support cryptography v41

This commit is contained in:
Brian Krabach
2026-04-03 21:39:03 -07:00
parent 4cca6d1c82
commit 89f39b2366
+3 -3
View File
@@ -91,7 +91,7 @@ def generate_self_signed(
.sign(private_key, hashes.SHA256())
)
expires = cert.not_valid_after_utc # type: ignore[attr-defined]
expires = getattr(cert, "not_valid_after_utc", cert.not_valid_after)
# Write key PEM — create file with restricted permissions before writing
key_pem = private_key.private_bytes(
@@ -154,8 +154,8 @@ def get_cert_info(cert_path) -> dict | None:
pass
return {
"expires": cert.not_valid_after_utc, # type: ignore[attr-defined]
"not_before": cert.not_valid_before_utc, # type: ignore[attr-defined]
"expires": getattr(cert, "not_valid_after_utc", cert.not_valid_after),
"not_before": getattr(cert, "not_valid_before_utc", cert.not_valid_before),
"hostnames": hostnames,
"serial": cert.serial_number,
}