X509Utils class
Helper class for certificate operations.
Constructors
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
andintermediate
. -
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 givenparent
. If theparent
parameter is null, the public key of the givenpem
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 thebegin
andend
. -
encodeDN(
Map< String, String> dn) → ASN1Object -
Encode the given
dn
(Distinguished Name) to aASN1Object
. -
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 thekey
and adding thebegin
andend
to thekey
. -
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 givenprivateKey
andpublicKey
. -
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 givenprivateKey
andpublicKey
. -
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 ofX509CertificateData
-
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.
Constants
- BEGIN_CERT → const String
- BEGIN_CRL → const String
- BEGIN_CSR → const String
- BEGIN_EC_PRIVATE_KEY → const String
- BEGIN_EC_PUBLIC_KEY → const String
- BEGIN_NEW_CSR → const String
- BEGIN_PKCS7 → const String
- BEGIN_PRIVATE_KEY → const String
- BEGIN_PUBLIC_KEY → const String
-
DN
→ const Map<
String, String> - END_CERT → const String
- END_CRL → const String
- END_CSR → const String
- END_EC_PRIVATE_KEY → const String
- END_EC_PUBLIC_KEY → const String
- END_NEW_CSR → const String
- END_PKCS7 → const String
- END_PRIVATE_KEY → const String
- END_PUBLIC_KEY → const String
- OCSP_REQUEST_MEDIATYPE → const String
- OCSP_RESPONSE_MEDIATYPE → const String