Skip to content

Support x509 Certificate, CSR, and CRL types in declarative ASN.1 API#14959

Merged
reaperhulk merged 4 commits into
mainfrom
claude/vibrant-edison-CqYD8
Jun 7, 2026
Merged

Support x509 Certificate, CSR, and CRL types in declarative ASN.1 API#14959
reaperhulk merged 4 commits into
mainfrom
claude/vibrant-edison-CqYD8

Conversation

@alex
Copy link
Copy Markdown
Member

@alex alex commented Jun 6, 2026

Fixes #14893

x509.Certificate, x509.CertificateSigningRequest, and x509.CertificateRevocationList can now be used as field types in asn1.sequence/asn1.set classes (and as top-level types for encode_der/decode_der), implemented as a special case for these three types in the ASN.1 code:

@asn1.sequence
class Example:
    cert: x509.Certificate
  • Encoding: writes the object's parsed DER structure directly into the output (EXPLICIT tagging supported).
  • Decoding: reads the field as a TLV and passes its full data to the existing load_der_x509_* loaders, so the usual validation (version checks, CRL inner/outer signature algorithm match) applies.
  • IMPLICIT annotations are rejected at class definition time (the original tag can't be recovered from an implicitly-tagged TLV), matching the existing TLV behavior.
  • Works inside OPTIONAL and CHOICE (tag-matched as SEQUENCE).

https://claude.ai/code/session_01TjVKLCXEtSPCRnAjTDYRtn


Generated by Claude Code

claude added 3 commits June 6, 2026 23:28
These three X.509 types can now be used as field types in asn1.sequence
and asn1.set classes (and as top-level types for encode_der/decode_der).
They are encoded by embedding their DER serialization, and decoded by
parsing the field with the existing X.509 loaders.

Fixes #14893

https://claude.ai/code/session_01TjVKLCXEtSPCRnAjTDYRtn
Decoding now reads a TLV and passes its full data to the existing
load_der_x509_* loaders instead of doing a full parse first. As a
consequence, IMPLICIT annotations are now rejected for X.509 field
types at class definition time (the original tag cannot be recovered
from an implicitly-tagged TLV), matching the existing TLV behavior.

https://claude.ai/code/session_01TjVKLCXEtSPCRnAjTDYRtn
The all-green CI job enforces 100% combined coverage; this covers the
error propagation when reading an X.509 field's TLV fails (empty
input) and the short-form branch of the _der_length test helper.

https://claude.ai/code/session_01TjVKLCXEtSPCRnAjTDYRtn
reaperhulk
reaperhulk previously approved these changes Jun 7, 2026
@reaperhulk reaperhulk enabled auto-merge (squash) June 7, 2026 00:12
@reaperhulk reaperhulk merged commit f7d5248 into main Jun 7, 2026
64 checks passed
@reaperhulk reaperhulk deleted the claude/vibrant-edison-CqYD8 branch June 7, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

asn1: Support integration with x509.Certificate, x509.CertificateSigningRequest, x509.CertificateRevocationList

3 participants