Merge pull request #78 from Cypheriel/timezone-fix

Fix time issue with cronreg
This commit is contained in:
danipoak 2023-12-09 13:03:32 -05:00 committed by GitHub
commit f205e86bdf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -276,10 +276,9 @@ async def main(args: argparse.Namespace):
if "P:" in str(user.user_id): if "P:" in str(user.user_id):
# logging.info(f"The user is: {user}") # logging.info(f"The user is: {user}")
cert = x509.load_pem_x509_certificate(user.id_cert.encode('utf-8')) 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}') logging.info(f'Certificate expires on: {expiration}')
reregister_time = expiration - datetime.timedelta(minutes=reregister_within) 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}') logging.info(f'Reregistration will occur at: {reregister_time}')
reregister_delta = (reregister_time - datetime.datetime.now(datetime.timezone.utc)).total_seconds() reregister_delta = (reregister_time - datetime.datetime.now(datetime.timezone.utc)).total_seconds()
logging.info( logging.info(