Skip to content

Commit db0c4af

Browse files
committed
fix: Use either x509.not_valid_after_utc or if it does not exist, x509.not_valid_after
1 parent 21a38d6 commit db0c4af

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

google/cloud/sql/connector/client.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,14 @@ async def _get_ephemeral(
234234
x509 = load_pem_x509_certificate(
235235
ephemeral_cert.encode("UTF-8"), default_backend()
236236
)
237-
expiration = x509.not_valid_after_utc
237+
238+
if 'not_valid_after_utc' in x509:
239+
expiration = x509.not_valid_after_utc
240+
elif 'not_valid_after' in x509:
241+
expiration = x509.not_valid_after
242+
else:
243+
expiration = datetime.MINYEAR
244+
238245
# for IAM authentication OAuth2 token is embedded in cert so it
239246
# must still be valid for successful connection
240247
if enable_iam_auth:

0 commit comments

Comments
 (0)