123456module juptune.data.x509.store;
Result loadFromCopyingDerBytes(
const ubyte[] derBytes,
bool hasImplicitTrust = false
);
Loads - and optionally validates - a certificate from the given raw DER encoding stored in derBytes. The resulting certificate is then stored within this certificate store.
This function copies the bytes within derBytesinto its internal storage, alleviating the user code from having to preserve the lifetime of derBytes. In other words, as long as this instance of X509CertificateStoreis alive, then all of the certificates this function parses will be alive.
To be clear, derBytesmust contain the DER encoding of the ASN.1 x.509 Certificatestructure.
Validation is only performed if hasImplicitTrustis false. If validation is performed, then trust anchor selection is performed. Please see the certiciate store's main documentation comment for details.
Set hasImplicitTrustto true for root certificates/trust anchors.
This function only loads a single certificate, for a certificate chain please see TODO
If an error is generated then no certificate is stored and any allocated memory for the certificate is immediately freed.
Anything that the underlying ASN.1 decoder functions can throw (`Asn1DecodeError`).
Anything that x509FromAsn1can throw.
Anything that X509ExtensionStore.fromCertificatecan throw.
Anything that x509ValidatePathcan throw.
X509StoreError.trustAnchorNotFoundif hasImplicitTrustis false and no trust anchor could be determined for the certificate.
X509StoreError.duplicateSubjectKeyIdif the certificate contains the subjectKeyIdentifier extension, and the identifier has already been used by a previous certificate.
A Resultindicating if an error occurred or not.