x509-parser icon indicating copy to clipboard operation
x509-parser copied to clipboard

Provide `as_raw` for all DER components?

Open chifflier opened this issue 5 years ago • 4 comments

This is the tracking issue for ideas discussed with @g2p in #35: can the parser expose the raw bytes for all components?

Maybe a possibility is to use something like nom-locate to parse items while tracking location in the input stream.

chifflier avatar Jul 08 '20 12:07 chifflier

Hey! I would love to have this API. Would you please implement it?

kpp avatar Jul 09 '21 12:07 kpp

This would be very helpful to extract the DER-serialization of individual certificate components - in my case, having access to the DER-encoding of SubjectPublicKeyInfo would be great to achieve interoperability with another crate.

nthuemmel-scontain avatar Jan 08 '24 13:01 nthuemmel-scontain

in my case, having access to the DER-encoding of SubjectPublicKeyInfo would be great to achieve interoperability with another crate.

@nthuemmel-scontain For this particular use case you should be able to use the raw field of the SubjectPublicKeyInfo struct:

A raw unparsed PKIX, ASN.1 DER form (see RFC 5280, Section 4.1).

cpu avatar Jan 08 '24 14:01 cpu

@nthuemmel-scontain For this particular use case you should be able to use the raw field of the SubjectPublicKeyInfo struct:

Thank you! You are right! For some reason, I assumed raw would cover only the subject_public_key, but it does indeed also cover the algorithm identifier. I guess I got confused by the mention of the parsed() method in the docs. (My assumption being that algorithm and subject_public_key cannot be the parsed equivalent of raw if there exists a separate fallible parsed() method.)

nthuemmel-scontain avatar Jan 08 '24 15:01 nthuemmel-scontain