X509CertificateBuilder class
Builder for X509 Certificates.
- Implemented types
Constructors
- X509CertificateBuilder(OpenSSL _context)
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addBasicConstraints(
{required bool isCa, int? pathLen, bool critical = false}) → void - Adds Basic Constraints extension (2.5.29.19).
-
addCertificatePolicies(
List< String> policyOids) → void - Adds Certificate Policies by OID.
-
addCrlDistributionPoints(
List< String> urls) → void - Adds CRL Distribution Points URLs.
-
addExtendedKeyUsage(
List< String> usages, {bool critical = false}) → void - Adds Extended Key Usage extension (2.5.29.37).
-
addIssuerEntry(
String field, String value) → void - Adds a single Issuer DN entry by field name (e.g. "CN", "O", "emailAddress").
-
addKeyUsage(
{bool digitalSignature = false, bool nonRepudiation = false, bool keyEncipherment = false, bool dataEncipherment = false, bool keyAgreement = false, bool keyCertSign = false, bool cRLSign = false, bool encipherOnly = false, bool decipherOnly = false, bool critical = false}) → void - Adds Key Usage extension (2.5.29.15).
-
addOcspUrls(
List< String> urls) → void - Adds OCSP URLs in Authority Information Access.
-
addRawExtensionByNid(
{required int nid, required Uint8List der, bool critical = false}) → void - Adds a raw extension by NID with DER-encoded value.
-
addSubjectAltNameOtherNames(
List< X509OtherName> otherNames) → void - Adds Subject Alternative Name (otherName) entries.
-
addSubjectAltNames(
{List< String> dnsNames = const [], List<String> emailAddresses = const [], List<String> ipAddresses = const [], List<String> uris = const [], bool critical = false}) → void - Adds Subject Alternative Names (2.5.29.17) of the common types.
-
addSubjectEntry(
String field, String value) → void - Adds a single Subject DN entry by field name (e.g. "CN", "O", "emailAddress").
-
dispose(
) → void - Releases the underlying X509 structure if the builder was not consumed.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setIssuer(
{String? commonName, String? organization, String? country, String? locality, String? state, String? unit, String? emailAddress, String? serialNumber, X509Certificate? issuerCert}) → void -
Sets the Issuer DN.
For self-signed certificates, this should be same as Subject.
If
issuerCertis provided, copies name from it. -
setIssuerAsSubject(
) → void - Helper for Self-Signed: Sets Issuer = Subject.
-
setPublicKey(
EvpPkey key) → void - Sets the Public Key.
-
setPublicKeyFromCsr(
X509Request csr) → void - Sets the Public Key from a CSR.
-
setSerialNumber(
int serial) → void - Sets the serial number.
-
setSerialNumberBigInt(
BigInt serial) → void - Sets the serial number using a BigInt (supports 64-160 bits as per RFC 5280).
-
setSubject(
{String? commonName, String? organization, String? country, String? locality, String? state, String? unit, String? emailAddress, String? serialNumber}) → void -
Sets the Subject DN (Distinguished Name).
Example:
builder.setSubject(commonName: 'My Cert', organization: 'My Org') -
setSubjectFromCsr(
X509Request csr) → void - Sets the Subject DN from a CSR.
-
setValidity(
{int notBeforeOffset = 0, int notAfterOffset = 31536000}) → void - Sets the validity period in seconds from now.
-
setValidityAdjEx(
{int notBeforeDays = 0, int notBeforeSeconds = 0, int notAfterDays = 365, int notAfterSeconds = 0}) → void - Sets validity using X509_time_adj_ex for fine-grained control.
-
setValidityAdjFromEpoch(
{required DateTime baseTime, int notBeforeDays = 0, int notBeforeSeconds = 0, int notAfterDays = 365, int notAfterSeconds = 0}) → void - Sets validity using ASN1_TIME_adj with a custom base time.
-
setValidityDates(
{required DateTime notBefore, required DateTime notAfter}) → void - Sets validity from explicit UTC dates (UTCTime/GeneralizedTime handled by OpenSSL).
-
setValidityFromStrings(
{required String notBefore, required String notAfter}) → void - Sets validity using explicit ASN.1 time strings.
-
sign(
EvpPkey privateKey, {String hashAlgorithm = 'SHA256'}) → X509Certificate -
Signs the certificate with a Private Key and returns the certificate wrapper.
hashAlgorithmdefaults to SHA256. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited