Skip to content

Commit 04f8fc1

Browse files
authored
Add timezone (utc) info into the cert not_valid_after field (#701)
* Add timezone (utc) info into the certificate datetime not_valid_after field. Signed-off-by: Christian S. Perone <christian.perone@gmail.com> * Removing timestamp from the comparison. Signed-off-by: Christian S. Perone <christian.perone@gmail.com> --------- Signed-off-by: Christian S. Perone <christian.perone@gmail.com>
1 parent bbf0ac8 commit 04f8fc1

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

sigstore/sign.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,9 @@ def _signing_cert(
137137
"""Get or request a signing certificate from Fulcio."""
138138
# If it exists, verify if the current certificate is expired
139139
if self.__cached_signing_certificate:
140-
if (
141-
datetime.now(timezone.utc).timestamp()
142-
> self.__cached_signing_certificate.cert.not_valid_after.timestamp()
143-
):
140+
not_valid_after = self.__cached_signing_certificate.cert.not_valid_after
141+
not_valid_after_tzutc = not_valid_after.replace(tzinfo=timezone.utc)
142+
if datetime.now(timezone.utc) > not_valid_after_tzutc:
144143
raise ExpiredCertificate
145144
return self.__cached_signing_certificate
146145

0 commit comments

Comments
 (0)