From 2809eeeaa47804f14b511b8d088d8568c5a28f04 Mon Sep 17 00:00:00 2001 From: Cypheriel <61402923+Cypheriel@users.noreply.github.com> Date: Fri, 8 Dec 2023 09:38:21 -0700 Subject: [PATCH 1/3] replace expiration timezone with utc --- demo.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/demo.py b/demo.py index 250565a..6046f13 100644 --- a/demo.py +++ b/demo.py @@ -276,10 +276,9 @@ async def main(args: argparse.Namespace): if "P:" in str(user.user_id): # logging.info(f"The user is: {user}") cert = x509.load_pem_x509_certificate(user.id_cert.encode('utf-8')) - expiration = cert.not_valid_after + expiration = cert.not_valid_after.astimezone() logging.info(f'Certificate expires on: {expiration}') reregister_time = expiration - datetime.timedelta(minutes=reregister_within) - reregister_time = reregister_time.astimezone(datetime.timezone.utc) logging.info(f'Reregistration will occur at: {reregister_time}') reregister_delta = (reregister_time - datetime.datetime.now(datetime.timezone.utc)).total_seconds() logging.info( From 9641cd34fddfb0ea42183769207159bc52c9bb45 Mon Sep 17 00:00:00 2001 From: Cypheriel <61402923+Cypheriel@users.noreply.github.com> Date: Fri, 8 Dec 2023 09:45:12 -0700 Subject: [PATCH 2/3] Revert "replace expiration timezone with utc" This reverts commit 2809eeeaa47804f14b511b8d088d8568c5a28f04. revert changes to demo.py --- demo.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/demo.py b/demo.py index 6046f13..250565a 100644 --- a/demo.py +++ b/demo.py @@ -276,9 +276,10 @@ async def main(args: argparse.Namespace): if "P:" in str(user.user_id): # logging.info(f"The user is: {user}") cert = x509.load_pem_x509_certificate(user.id_cert.encode('utf-8')) - expiration = cert.not_valid_after.astimezone() + expiration = cert.not_valid_after logging.info(f'Certificate expires on: {expiration}') reregister_time = expiration - datetime.timedelta(minutes=reregister_within) + reregister_time = reregister_time.astimezone(datetime.timezone.utc) logging.info(f'Reregistration will occur at: {reregister_time}') reregister_delta = (reregister_time - datetime.datetime.now(datetime.timezone.utc)).total_seconds() logging.info( From 064c8b19a79cea168d89363adb0498a6e1f93988 Mon Sep 17 00:00:00 2001 From: Cypheriel <61402923+Cypheriel@users.noreply.github.com> Date: Fri, 8 Dec 2023 09:47:17 -0700 Subject: [PATCH 3/3] actually fix the timezone bug --- demo.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/demo.py b/demo.py index 250565a..276dbd4 100644 --- a/demo.py +++ b/demo.py @@ -276,10 +276,9 @@ async def main(args: argparse.Namespace): if "P:" in str(user.user_id): # logging.info(f"The user is: {user}") cert = x509.load_pem_x509_certificate(user.id_cert.encode('utf-8')) - expiration = cert.not_valid_after + expiration = cert.not_valid_after.replace(tzinfo=datetime.timezone.utc) logging.info(f'Certificate expires on: {expiration}') reregister_time = expiration - datetime.timedelta(minutes=reregister_within) - reregister_time = reregister_time.astimezone(datetime.timezone.utc) logging.info(f'Reregistration will occur at: {reregister_time}') reregister_delta = (reregister_time - datetime.datetime.now(datetime.timezone.utc)).total_seconds() logging.info(