Object built-in object

Object X509Req

x509 certificate request object

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

1
var k = new crypto.X509Req();

Inheritance

Constructor

X509Req

X509Req constructor

1
new X509Req();

X509Req constructor to create a certificate request based on the given information

1 2 3
new X509Req(String subject, PKey key, Integer hash = hash.SHA1);

Call parameters:

  • subject : String, the distinguished name of the subject of the certificate
  • key : PKey , the public key of the certificate
  • hash : Integer, certificate digest algorithm, default is hash.SHA1

X509Req constructor, load a certificate request in DER format

1
new X509Req(Buffer derReq);

Call parameters:

  • derReq : Buffer , DER format certificate request

X509Req constructor, load a certificate request in PEM format

1
new X509Req(String pemReq);

Call parameters:

  • pemReq : String, DER format certificate request

Member attributes

subject

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

1
readonly String X509Req.subject;

publicKey

PKey , get the public key of the certificate

1
readonly PKey X509Req.publicKey;

Member function

load

Load a certificate request in DER format

1
X509Req.load(Buffer derReq);

Call parameters:

  • derReq : Buffer , DER format certificate request

Load a certificate request in PEM format

1
X509Req.load(String pemReq);

Call parameters:

  • pemReq : String, certificate request in PEM format

loadFile

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

1
X509Req.loadFile(String filename);

Call parameters:

  • filename : String, certificate request file name

exportPem

Returns the PEM format encoding of the current certificate request

1
String X509Req.exportPem();

Return result:

  • String , the PEM format encoding of the current certificate request

exportDer

Returns the DER format encoding of the current certificate request

1
Buffer X509Req.exportDer();

Return result:

  • Buffer , the DER format encoding of the current certificate request

sign

Sign the current certificate request as an official certificate

1 2 3
X509Cert X509Req.sign(String issuer, PKey key, Object opts = {}) async;

Call parameters:

  • issuer : String, the distinguished name of the signing authority
  • key : PKey , the private key of the signing authority
  • opts : Object, other optional parameters

Return result:

  • X509Cert , return the signed official certificate

The fields received by opts are as follows:

1 2 3 4 5 6 7 8
{ ca: false, // 证书为 ca,缺省为 false pathlen: -1, // 证书深度,缺省为 -1 notBefore: "", // 证书生效时间,缺省为当前时间 notAfter: "", // 证书失效时间,缺省为 notBefore 后一年 usage: "", // 证书使用范围,接收:digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment, keyAgreement, keyCertSign, cRLSign type: "" // 证书 Netscape 证书类型,接收:client, server, email, objsign, reserved, sslCA, emailCA, objCA }

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 X509Req.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 X509Req.toJSON(String key = "");

Call parameters:

  • key : String, unused

Return result:

  • Value , returns a value containing JSON serializable