Skip to content

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

@loewexy

Description

@loewexy

While working with the new asn1 library to implement the CMS format i missed one integration between the asn1 module and the x509.* classes. It would be nice if something like the following could work.

@asn1.sequence
class Test:
  cert: x509.Certificate

To include the Certificate, CSR or CRL objects that cryptography already has in the structure, without complexity. Currently the only option would be to do someting like:

_cert = load_pem_certificate(...)

@asn1.sequence
class Test:
  cert: asn1.TLV

# Create object
obj = Test(cert=asn1.TLV(
  _cert.public_bytes(encoding=Encoding.DER)
))

# Get cert from object
_cert_from_obj = load_der_certificate(obj.cert)

And i am not even sure if this would work. But nevertheless it is not a nice solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions