Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong typing on get_revoked_certificate_by_serial_number #12081

Closed
magnuswatn opened this issue Dec 1, 2024 · 0 comments · Fixed by #12082
Closed

Wrong typing on get_revoked_certificate_by_serial_number #12081

magnuswatn opened this issue Dec 1, 2024 · 0 comments · Fixed by #12082

Comments

@magnuswatn
Copy link
Contributor

After #11991 the typed return value from get_revoked_certificate_by_serial_number()on CertificateRevocationList is cryptography.hazmat.bindings._rust.x509.RevokedCertificate instead of cryptography.x509.base.RevokedCertificate (which is what the iterator returns). They should probably match.

from typing import reveal_type

from cryptography import x509


def load_crl_and_print_revocation_date(crl_bytes: bytes) -> None:
    crl = x509.load_der_x509_crl(crl_bytes)
    revoked_cert = crl.get_revoked_certificate_by_serial_number(123)

    assert revoked_cert is not None

    reveal_type(revoked_cert)

    print(revoked_cert.revocation_date_utc)

With cryptography 43.0.3:

❯ mypy testulf.py
testulf.py:12: note: Revealed type is "cryptography.x509.base.RevokedCertificate"
Success: no issues found in 1 source file

With cryptography 44.0.0:

❯ mypy testulf.py
testulf.py:12: note: Revealed type is "cryptography.hazmat.bindings._rust.x509.RevokedCertificate"
testulf.py:14: error: "RevokedCertificate" has no attribute "revocation_date_utc"  [attr-defined]
Found 1 error in 1 file (checked 1 source file)
magnuswatn added a commit to magnuswatn/sertifikatsok that referenced this issue Dec 2, 2024
Latest version has a typing error:
pyca/cryptography#12081
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant