Merge "Replace use of deprecated cert.not_valid_after"
This commit is contained in:
commit
fcc61e9ca8
@ -300,7 +300,7 @@ def get_cert_expiration(certificate_pem):
|
||||
try:
|
||||
cert = x509.load_pem_x509_certificate(certificate_pem,
|
||||
backends.default_backend())
|
||||
return cert.not_valid_after
|
||||
return cert.not_valid_after_utc
|
||||
except Exception as e:
|
||||
LOG.exception('Unreadable Certificate.')
|
||||
raise exceptions.UnreadableCert from e
|
||||
|
@ -246,7 +246,10 @@ class TestTLSParseUtils(base.TestCase):
|
||||
|
||||
def test_get_cert_expiration(self):
|
||||
exp_date = cert_parser.get_cert_expiration(sample_certs.X509_EXPIRED)
|
||||
self.assertEqual(datetime.datetime(2016, 9, 25, 18, 1, 54), exp_date)
|
||||
self.assertEqual(
|
||||
datetime.datetime(2016, 9, 25, 18, 1, 54,
|
||||
tzinfo=datetime.timezone.utc),
|
||||
exp_date)
|
||||
|
||||
# test the exception
|
||||
self.assertRaises(exceptions.UnreadableCert,
|
||||
|
Loading…
Reference in New Issue
Block a user