From 196f5588cc61e6531cda9491f3eb26f152630528 Mon Sep 17 00:00:00 2001 From: downtownallday Date: Mon, 7 Oct 2024 09:51:56 -0400 Subject: [PATCH] eliminate the use of deprecated utcnow() --- management/ssl_certificates.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/management/ssl_certificates.py b/management/ssl_certificates.py index dd3106d97..888a6d96b 100755 --- a/management/ssl_certificates.py +++ b/management/ssl_certificates.py @@ -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 "") @@ -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)