Description
CertificateBuilder::add_extension
has the following public interface:
formats/x509-cert/src/builder.rs
Lines 196 to 197 in e0c3e08
If I follow the breadcrumb trail to the AsExtension
trait, I get this as the public API that needs implementing for a custom extension:
Lines 47 to 51 in e0c3e08
-
AssociatedOid
makes enough sense to me. -
der::Encode
is somewhat confusing, because its documentation is just:Encoding trait.
The method documentation is a little better:
Encode this value as ASN.1 DER using the provided Writer.
However, it is unclear how the output of this method will be treated. My particular example is the YubiKey PIV attestation policy extension, which is documented as:
Extensions in the generated certificate:
- ...
1.3.6.1.4.1.41482.3.8
: Two bytes, the first encoding pin policy and the second touch policy
Should that map to two raw ASN.1 bytes? Is there some other ASN.1 DER wrapper around it that I need to know about? This should be handled in the
yubikey
crate (which I will upstream my impl to), but it is unclear what kind of verification happens on the output ofder::Encode::encode
. -
AsExtension::critical
makes zero sense to me. What is a "critical extension" and how should I decide whether mine is? There is no description here to guide me, or any references to external documentation I should read before deciding what to return here.
It would be helpful to improve documentation across the board here, but in particular:
CertificateBuilder::add_extension
should document where to find existing extensions (a direct link to the list ofAsExtension
implementors would be ideal).- Either
CertificateBuilder::add_extension
orAsExtension
should document how to go about implementing a custom extension, with considerations about correctness (how to ensure everyone can parse your extension), best practices, and whatever criticality is.