Object built-in object

Object X509Cert

x509 certificate object

The X509Cert object belongs to the crypto module and is created:

1
var k = new crypto.X509Cert();

Inheritance

Constructor

X509Cert

X509Cert constructor

1
new X509Cert();

X509Cert constructor, load a certificate in DER format

1
new X509Cert(Buffer derCert);

Call parameters:

  • derCert : Buffer , DER format certificate

X509Cert constructor, load a certificate in CRT/PEM/TXT format

1
new X509Cert(String txtCert);

Call parameters:

  • txtCert : String, CRT/PEM/TXT format certificate

load Load mozilla's certdata, txt, which can be downloaded and used at http

Member attributes

version

Integer, obtain the version of the certificate

1
readonly Integer X509Cert.version;

serial

String, get the serial number of the certificate

1
readonly String X509Cert.serial;

issuer

String, get the distinguished name of the certificate issuer

1
readonly String X509Cert.issuer;

subject

String, the distinguished name of the subject to obtain the certificate

1
readonly String X509Cert.subject;

notBefore

Date, the effective time of obtaining the certificate

1
readonly Date X509Cert.notBefore;

notAfter

Date, the expiration time of the obtained certificate

1
readonly Date X509Cert.notAfter;

ca

Boolean, whether the obtained certificate is a CA certificate

1
readonly Boolean X509Cert.ca;

pathlen

Integer, pathlen to obtain the certificate

1
readonly Integer X509Cert.pathlen;

usage

String, the scope of use to obtain the certificate

1
readonly String X509Cert.usage;

The result is all or part of the following: digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment, keyAgreement, keyCertSign, cRLSign


type

String, Netscape certificate type to obtain the certificate

1
readonly String X509Cert.type;

The result is all or part of the following: client, server, email, objsign, reserved, sslCA, emailCA, objCA


publicKey

PKey , get the public key of the certificate

1
readonly PKey X509Cert.publicKey;

next

X509Cert, get the next certificate in the certificate chain

1
readonly X509Cert X509Cert.next;

Member function

load

Load a certificate in DER format, which can be called multiple times

1
X509Cert.load(Buffer derCert);

Call parameters:

  • derCert : Buffer , DER format certificate

Load a certificate in CRT/PEM/TXT format, which can be called multiple times

1
X509Cert.load(String txtCert);

Call parameters:

  • txtCert : String, CRT/PEM/TXT format certificate

load Load mozilla's certdata, txt, which can be downloaded and used at http


loadFile

Load a certificate in CRT/PEM/DER/TXT format, which can be called multiple times

1
X509Cert.loadFile(String filename);

Call parameters:

  • filename : String, certificate file name

loadFile loads mozilla's certdata,txt, which can be downloaded and used at http


loadRootCerts

Load the default root certificate that comes with it

1
X509Cert.loadRootCerts();

The content of this certificate comes from: http ://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt


verify

Use the current certificate chain to verify the given certificate

1
Boolean X509Cert.verify(X509Cert cert) async;

Call parameters:

  • cert : X509Cert, given the certificate to be verified

Return result:

  • Boolean , return True if the verification is successful

dump

Export the loaded certificate

1
Array X509Cert.dump(Boolean pem = true);

Call parameters:

  • pem : Boolean, specify to output the revoked certificate in PEM format, the default is true

Return result:

  • Array , export the certificate chain as an array

clear

Clear the loaded certificate

1
X509Cert.clear();

toString

Returns the string representation of the object, generally returns "[Native Object]", the object can be re-implemented according to its own characteristics

1
String X509Cert.toString();

Return result:

  • String , returns the string representation of the object

toJSON

Returns the JSON format representation of the object, generally returns a collection of readable attributes defined by the object

1
Value X509Cert.toJSON(String key = "");

Call parameters:

  • key : String, unused

Return result:

  • Value , returns a value containing JSON serializable