License
BSD-3-Clause
X.509 Certificate Chain Validation (RFC 5280).
Provides functions for building and validating certificate chains, including signature verification, validity period checks, and extension validation.
Result of certificate chain validation.
Options for certificate chain validation.
long validationTimeThe time to use for validity checks (Unix timestamp). If 0, validation is skipped.bool verifySignaturesWhether to verify signatures in the chain.bool checkKeyUsageWhether to check key usage extensions.bool checkBasicConstraintsWhether to check basic constraints.bool checkCriticalExtensionsWhether to check for unrecognized critical extensions.string requiredPurposePurpose OID to check in Extended Key Usage (null to skip).Detailed result of certificate chain validation.
ValidationResult resultThe overall validation resultstring errorMessageHuman-readable error message (if validation failed)int failingCertIndexIndex of the certificate that caused the failure (-1 if N/A)X509Certificate[] chainThe validated certificate chain (from end-entity to root)A collection of trusted root certificates.
The trust store is used during chain validation to determine whether a certificate chain terminates at a trusted root.
private X509Certificate[] _trustedRootsvoid addTrustedRoot(X509Certificate cert)Adds a trusted root certificate.void addTrustedRoots(X509Certificate[] certs)Adds multiple trusted root certificates.void loadFromPem(string pem)Loads trusted roots from PEM data containing multiple certificates.X509Certificate findIssuer(X509Certificate cert)Finds a trusted root that issued the given certificate.bool isTrusted(X509Certificate cert)Checks if a certificate is in the trust store.this()Creates an empty trust store.ValidationReport validateChain(X509Certificate[] chain, TrustStore trustStore,
ValidationOptions options = ValidationOptions.init)Validates a certificate chain against a trust store.bool verifySignature(X509Certificate cert, X509Certificate issuer)Verifies that a certificate was signed by the given issuer.bool verifySignatureWithKey(X509Certificate cert, PublicKey publicKey)Verifies a certificate's signature using a public key.bool verifyRsaPkcs1Signature(X509Certificate cert, PublicKey publicKey, Hash hash)Verifies an RSA PKCS#1 v1.5 signature.bool verifyPkcs1Padding(ubyte[] em, ubyte[] expectedHash, size_t hashLen)Verifies PKCS#1 v1.5 padding and compares hash.bool verifyEcdsaSignature(X509Certificate cert, PublicKey publicKey,
Hash delegate() hashFactory)Verifies an ECDSA signature.bool verifyEd25519Signature(X509Certificate cert, PublicKey publicKey)Verifies an Ed25519 signature.bool isRecognizedExtension(string oid) pure nothrow @safeChecks if an extension OID is recognized.size_t findMarker(string data, string marker, size_t start) pure nothrow @safeFinds a marker string in PEM data.bool verifyHostname(X509Certificate cert, string hostname) @safeVerifies that a certificate is valid for the given hostname.bool matchHostname(string pattern, string hostname) pure @trustedMatches a hostname pattern against a hostname.