Skip to content

Commit

Permalink
Fill in notBefore/notAfter in X509 _PKeyInteractionTestsMixin tests (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
davidben authored Sep 7, 2021
1 parent 30e82d4 commit 8e1f599
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/test_crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,7 @@ class _PKeyInteractionTestsMixin:

def signable(self):
"""
Return something with a `set_pubkey`, `set_pubkey`, and `sign` method.
Return something with `set_pubkey` and `sign` methods.
"""
raise NotImplementedError()

Expand Down Expand Up @@ -1715,7 +1715,12 @@ def signable(self):
"""
Create and return a new `X509`.
"""
return X509()
certificate = X509()
# Fill in placeholder validity values. signable only expects to call
# set_pubkey and sign.
certificate.gmtime_adj_notBefore(-24 * 60 * 60)
certificate.gmtime_adj_notAfter(24 * 60 * 60)
return certificate

def test_type(self):
"""
Expand Down

0 comments on commit 8e1f599

Please sign in to comment.