Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update utcnow to now(timezone.utc) #189

Merged
merged 2 commits into from
Dec 21, 2023
Merged

Conversation

jackwotherspoon
Copy link
Collaborator

@jackwotherspoon jackwotherspoon commented Dec 21, 2023

In Python 3.12 the use of utcnow() is deprecated. https://discuss.python.org/t/deprecating-utcnow-and-utcfromtimestamp/26221

This also updates the timestamps from naive timestamps to aware timestamps.

@jackwotherspoon jackwotherspoon self-assigned this Dec 21, 2023
@@ -92,7 +92,7 @@ def __init__(
ca_cert, cert_chain = certs
# get expiration from client certificate
cert_obj = x509.load_pem_x509_certificate(cert_chain[0].encode("UTF-8"))
self.expiration = cert_obj.not_valid_after
self.expiration = cert_obj.not_valid_after.replace(tzinfo=timezone.utc)
Copy link
Collaborator Author

@jackwotherspoon jackwotherspoon Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cert is in UTC "Zulu" format so making it timezone aware for utc is fine here (basically a no-op).
https://cloud.google.com/sql/docs/mysql/admin-api/rest/v1beta4/sslCerts#SslCert

@jackwotherspoon jackwotherspoon merged commit 0d0278e into main Dec 21, 2023
15 checks passed
@jackwotherspoon jackwotherspoon deleted the utcnow-deprecation branch December 21, 2023 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants