ddn.crypto.x509.certificate
X.509 Certificate Parsing and Representation (RFC 5280).
Provides types and functions for parsing X.509 certificates from DER or PEM format, extracting public keys, and accessing certificate fields and extensions.
Copyright
Types 11
X.509 certificate version.
The version field indicates the syntax version of the certificate.
Key usage flags as defined in RFC 5280 Section 4.2.1.3.
These flags indicate the purpose of the public key contained in the certificate.
General name type for Subject Alternative Name extension.
Represents an X.500 Distinguished Name (DN).
A DN is an ordered sequence of Relative Distinguished Names (RDNs), each containing one or more attribute type-value pairs.
RDN[] rdnsThe RDN components in orderstring getAttribute(string oid) const pure nothrow @safeReturns the first value for the given OID, or null if not found.string commonName() @property const pure nothrow @safeReturns the Common Name (CN) attribute, or null if not present.string organization() @property const pure nothrow @safeReturns the Organization (O) attribute, or null if not present.string country() @property const pure nothrow @safeReturns the Country (C) attribute, or null if not present.A Relative Distinguished Name, containing one or more attributes.
AttributeTypeAndValue[] attributesThe attribute type-value pairs in this RDNAn attribute type-value pair within an RDN.
string oidThe attribute type OID in dotted-decimal formstring valueThe attribute value as a stringCertificate validity period.
long notBeforeThe time the certificate becomes valid (Unix timestamp)long notAfterThe time the certificate expires (Unix timestamp)bool isValidAt(long unixTime) const pure nothrow @safe @nogcChecks if the given time falls within the validity period.A general name from the Subject Alternative Name extension.
GeneralNameType typeThe type of this general namestring valueThe value (interpretation depends on type)ubyte[] ipBytesFor IP addresses, the raw bytesBasic Constraints extension data.
bool isCAWhether this certificate is a CA certificateint pathLenConstraintMaximum path length (number of intermediate CAs allowed), -1 if not specifiedAn X.509 certificate extension.
string oidThe extension OID in dotted-decimal formbool criticalWhether the extension is marked criticalubyte[] valueThe raw extension value bytes (DER-encoded)Represents a parsed X.509 certificate.
This class provides access to all certificate fields, extensions, and the subject public key. It supports parsing from DER or PEM format.
X509Version certVersionThe certificate version (v1, v2, or v3)ubyte[] serialNumberThe certificate serial number as big-endian bytesstring signatureAlgorithmThe signature algorithm OID used by the issuerubyte[] signatureParametersThe signature algorithm parameters (may be empty)DistinguishedName issuerThe issuer Distinguished NameValidity validityThe certificate validity periodDistinguishedName subjectThe subject Distinguished Namestring publicKeyAlgorithmThe subject public key algorithm OIDubyte[] publicKeyParametersThe subject public key algorithm parameters (e.g., curve OID for EC)ubyte[] publicKeyBitsThe subject public key bitsubyte[] subjectPublicKeyInfoThe raw SubjectPublicKeyInfo DER bytesX509Extension[] extensionsThe certificate extensions (empty for v1/v2 certs)ubyte[] signatureValueThe signature valueubyte[] tbsCertificateDerThe raw TBSCertificate DER bytes (for signature verification)ubyte[] rawDerThe complete certificate DER bytesbool hasExtension(string oid) const pure nothrow @safeChecks if an extension with the given OID exists.GeneralName[] getSubjectAltNames() const @trustedParses and returns the Subject Alternative Name extension.bool isSelfSigned() @property constChecks if the certificate is self-signed (issuer equals subject).Functions 19
X509Certificate parseX509Certificate(const(ubyte)[] der)Parses an X.509 certificate from DER-encoded bytes.DistinguishedName parseDistinguishedName(ref DerReader reader)Parses a Distinguished Name from the current position in the reader.long parseTime(Asn1Value tlv)Parses a Time value (UTCTime or GeneralizedTime) to Unix timestamp.void parseSubjectPublicKeyInfo(const(ubyte)[] content, X509Certificate cert)Parses SubjectPublicKeyInfo and populates certificate fields.BasicConstraints parseBasicConstraints(const(ubyte)[] value)Parses a Basic Constraints extension value.GeneralName[] parseSubjectAltName(const(ubyte)[] value)Parses a Subject Alternative Name extension value.string[] parseExtendedKeyUsage(const(ubyte)[] value)Parses an Extended Key Usage extension value.string parseStringValue(Asn1Value tlv) pureParses an ASN.1 string value (UTF8String, PrintableString, etc.).string oidToShortName(string oid) pure nothrow @safeConverts an OID to a short name for DN display.string escapeRdn(string value) pure @safeEscapes special characters in an RDN value for RFC 2253 output.long toUnixTime(int year, int month, int day, int hour, int minute, int second) pure nothrow @safeConverts date components to Unix timestamp (assumes UTC).