Adds an Authority Key Identifier extension to the certificate.
The authority key identifier bytes
This builder for chaining
Adds a Basic Constraints extension to the certificate.
Whether this is a CA certificate
OptionalpathLenConstraint: numberOptional path length constraint
This builder for chaining
Adds an Extended Key Usage extension to the certificate.
Extended key usage purposes
This builder for chaining
Adds an extension to the certificate.
The extension to add
This builder for chaining
Adds multiple extensions to the certificate.
Array of extensions to add
This builder for chaining
Adds a Key Usage extension to the certificate.
Key usage flags
This builder for chaining
Adds a Subject Alternative Name extension to the certificate. Strings are automatically converted to DNS names.
Alternative names for the subject (strings or GeneralName objects)
This builder for chaining
// Simple DNS names as strings
builder.addSubjectAltName('example.com', '*.example.com')
// Or use GeneralName objects for other types
builder.addSubjectAltName(
new GeneralName.dNSName({ value: 'example.com' }),
new GeneralName.rfc822Name({ value: 'admin@example.com' })
)
// Mix strings and GeneralName objects
builder.addSubjectAltName(
'example.com',
new GeneralName.rfc822Name({ value: 'admin@example.com' })
)
Adds a Subject Key Identifier extension to the certificate.
The key identifier bytes
This builder for chaining
Alias for sign() to match the AsyncBuilder interface. Builds a CA-signed certificate, or self-signed if no issuer is set.
Promise resolving to the signed certificate
Generates a random serial number.
This builder for chaining
Builds and signs a self-signed certificate.
Promise resolving to the signed certificate
Sets the signature algorithm.
Algorithm parameters or SignatureAlgorithmIdentifier
This builder for chaining
Sets the issuer for the certificate. For self-signed certificates, this will be set to match the subject.
Issuer DN as string, Name object, or Certificate
This builder for chaining
Sets the issuer's private key for signing (for CA-signed certificates).
The issuer's private key
This builder for chaining
Sets the private key for signing (for self-signed certificates).
The private key
This builder for chaining
Sets the subject's public key.
The subject's public key
This builder for chaining
Sets the serial number for the certificate.
Serial number as bytes, number, or string
This builder for chaining
Sets the subject distinguished name for the certificate.
Subject DN as string or Name object
This builder for chaining
Sets the validity period in days from now.
Number of days the certificate should be valid
This builder for chaining
Sets the validity period for the certificate.
Start of validity period
End of validity period
This builder for chaining
Sets the certificate version.
Certificate version (0 = v1, 1 = v2, 2 = v3)
This builder for chaining
Builds and signs a certificate with the specified issuer.
Promise resolving to the signed certificate
Builder class for creating X.509 certificates.
This builder provides a fluent API for constructing certificates with various options including subject, issuer, validity period, extensions, and more. It supports both self-signed and CA-signed certificates.
Example