Skip to content

Commit 310cf31

Browse files
committed
Replace use of deprecated cert.not_valid_after
... attribute. See [1] [1]: https://cryptography.io/en/latest/x509/reference/#cryptography.x509.Certificate.not_valid_after Change-Id: I3dd573300a8dfbe68eaeb736b47f6abb61b5e85b
1 parent 5416823 commit 310cf31

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

octavia/common/tls_utils/cert_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def get_cert_expiration(certificate_pem):
300300
try:
301301
cert = x509.load_pem_x509_certificate(certificate_pem,
302302
backends.default_backend())
303-
return cert.not_valid_after
303+
return cert.not_valid_after_utc
304304
except Exception as e:
305305
LOG.exception('Unreadable Certificate.')
306306
raise exceptions.UnreadableCert from e

octavia/tests/unit/common/tls_utils/test_cert_parser.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@ def test_get_primary_cn(self):
246246

247247
def test_get_cert_expiration(self):
248248
exp_date = cert_parser.get_cert_expiration(sample_certs.X509_EXPIRED)
249-
self.assertEqual(datetime.datetime(2016, 9, 25, 18, 1, 54), exp_date)
249+
self.assertEqual(
250+
datetime.datetime(2016, 9, 25, 18, 1, 54,
251+
tzinfo=datetime.timezone.utc),
252+
exp_date)
250253

251254
# test the exception
252255
self.assertRaises(exceptions.UnreadableCert,

0 commit comments

Comments
 (0)