Skip to content

Commit

Permalink
eliminate the use of deprecated utcnow()
Browse files Browse the repository at this point in the history
  • Loading branch information
downtownallday committed Oct 7, 2024
1 parent dd16008 commit 196f558
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions management/ssl_certificates.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def get_file_list():

# Sort the certificates to prefer good ones.
import datetime
now = datetime.datetime.utcnow()
now = datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None)
ret = { }
for domain, cert_list in domains.items():
#for c in cert_list: print(domain, c["cert"].not_valid_before, c["cert"].not_valid_after, "("+str(now)+")", c["cert"].issuer, c["cert"].subject, c._filename if hasattr(c,"_filename") else "")
Expand Down Expand Up @@ -579,7 +579,7 @@ def check_certificate(domain, ssl_certificate, ssl_private_key, warn_if_expiring
# Check that the certificate hasn't expired. The datetimes returned by the
# certificate are 'naive' and in UTC. We need to get the current time in UTC.
import datetime
now = datetime.datetime.utcnow()
now = datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None)
if not(cert.not_valid_before <= now <= cert.not_valid_after):
return (f"The certificate has expired or is not yet valid. It is valid from {cert.not_valid_before} to {cert.not_valid_after}.", None)

Expand Down

0 comments on commit 196f558

Please sign in to comment.