X509Utils class

Helper class for certificate operations.

Constructors

X509Utils()

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

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

buildOCSPRequest(String pem, {String? intermediate}) → ASN1Sequence
Builds a OCSPRquest out of the given pem and intermediate.
checkChain(List<X509CertificateData> x509) CertificateChainCheckData
Checks a given certificate chain. For each pair it checks the issuer/subject values and the signature.
checkCsrSignature(String pem) bool
Checks the signature of the given CSR if it matches the content of the CSR.
checkX509Signature(String pem, {String? parent}) bool
Checks the signature of the given pem by using the public key from the given parent. If the parent parameter is null, the public key of the given pem will be used.
crlDataFromPem(String pem) CertificateRevokeListeData
crlDerToPem(Uint8List bytes) String
Converts the given DER encoded CRL to a PEM string with the corresponding headers. The given bytes can be taken directly from a .crl file.
csrFromPem(String pem) CertificateSigningRequestData
Parses the given CSR pem to CertificateSigningRequestData object
eccSign(Uint8List inBytes, ECPrivateKey privateKey, String signingAlgorithm) ECSignature
encodeASN1ObjectToPem(ASN1Object asn1Object, String begin, String end, {String newLine = '\n'}) String
Encode the given asn1Object to PEM format and adding the begin and end.
encodeDN(Map<String, String> dn) → ASN1Object
Encode the given dn (Distinguished Name) to a ASN1Object.
fixPem(String pem) String
Trys to fix the given pem string.
formatKeyString(String key, String begin, String end, {int chunkSize = 64, String lineDelimiter = '\n'}) String
Formats the given key by chunking the key and adding the begin and end to the key.
generateEccCsrPem(Map<String, String> attributes, ECPrivateKey privateKey, ECPublicKey publicKey, {List<String>? san, String signingAlgorithm = 'SHA-256'}) String
Generates a eliptic curve Certificate Signing Request with the given attributes using the given privateKey and publicKey.
generateRsaCsrPem(Map<String, String> attributes, RSAPrivateKey privateKey, RSAPublicKey publicKey, {List<String>? san, String signingAlgorithm = 'SHA-256'}) String
Generates a Certificate Signing Request with the given attributes using the given privateKey and publicKey.
generateSelfSignedCertificate(PrivateKey privateKey, String csr, int days, {List<String>? sans, List<KeyUsage>? keyUsage, List<ExtendedKeyUsage>? extKeyUsage, String serialNumber = '1', Map<String, String>? issuer, DateTime? notBefore}) String
Generates a self signed certificate
getModulusFromRSACsrPem(String pem) BigInt
Returns the modulus of the given pem that represents an RSA CSR.
getModulusFromRSAX509Pem(String pem) BigInt
Returns the modulus of the given pem that represents an RSA X509 certificate.
getOCSPUrl(String pem) String
Fetches the OSCP url for the given certificate as pem. Supporting X509 and PKCS7 PEMs.
parseChainString(String chain) List<X509CertificateData>
Converts the given chain to a list of X509CertificateData
parseChainStringAsString(String s) List<String>
Converts the given chain to a list of pem strings.
parseOCSPResponse(Uint8List bytes) OCSPResponse
Parses an OCSPResponse from the given bytes received by an OCSP responder.
pemToPkcs7(List<String> certPems) String
Converts the given single pems to a PKCS7 pem string according to datatracker.ietf.org/doc/html/rfc2315
pkcs7fromPem(String pem) Pkcs7CertificateData
Parses the given PEM
privateKeyFromASN1Sequence(ASN1Sequence asnSequence) RSAPrivateKey
Decode the given asnSequence into an RSAPrivateKey.
x509CertificateFromPem(String pem) X509CertificateData
Parses the given PEM to a X509CertificateData object.