Skip to content

Commit 8e1f599

Browse files
authored
Fill in notBefore/notAfter in X509 _PKeyInteractionTestsMixin tests (#1039)
While the tests currently pass without it, this is because OpenSSL's encoder doesn't notice that it is emitting garbage. See openssl/openssl#16538 Fill in a placeholder validity period so the tests both better mirror real X.509 signing code and do not rely on this bug.
1 parent 30e82d4 commit 8e1f599

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tests/test_crypto.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@ class _PKeyInteractionTestsMixin:
14681468

14691469
def signable(self):
14701470
"""
1471-
Return something with a `set_pubkey`, `set_pubkey`, and `sign` method.
1471+
Return something with `set_pubkey` and `sign` methods.
14721472
"""
14731473
raise NotImplementedError()
14741474

@@ -1715,7 +1715,12 @@ def signable(self):
17151715
"""
17161716
Create and return a new `X509`.
17171717
"""
1718-
return X509()
1718+
certificate = X509()
1719+
# Fill in placeholder validity values. signable only expects to call
1720+
# set_pubkey and sign.
1721+
certificate.gmtime_adj_notBefore(-24 * 60 * 60)
1722+
certificate.gmtime_adj_notAfter(24 * 60 * 60)
1723+
return certificate
17191724

17201725
def test_type(self):
17211726
"""

0 commit comments

Comments
 (0)