The docs for get_notBefore and get_notAfter say:
A timestamp string, or None if there is none.
https://pyopenssl.org/en/stable/api/crypto.html#OpenSSL.crypto.X509.get_notAfter
But there is no such thing as a certificate without a notBefore or notAfter. They're not optional fields. What can happen is that the string is invalid, if the underlying OpenSSL's parser defers rejecting bad time values. So perhaps it should say "or None if the timestamp could not be parsed" or something like that.
The docs for get_notBefore and get_notAfter say:
But there is no such thing as a certificate without a notBefore or notAfter. They're not optional fields. What can happen is that the string is invalid, if the underlying OpenSSL's parser defers rejecting bad time values. So perhaps it should say "or None if the timestamp could not be parsed" or something like that.