Class Index | File Index

Classes


Class KJUR.asn1.csr.CertificationRequest


Extends KJUR.asn1.ASN1Object.
ASN.1 CertificationRequest structure class
Defined in: asn1csr-1.0.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
ASN.1 CertificationRequest structure class This class provides CertificateRequestInfo ASN.1 structure defined in RFC 2986 4.2.
Fields borrowed from class KJUR.asn1.ASN1Object:
hL, hT, hTLV, hV, isModified, params
Method Summary
Method Attributes Method Name and Description
 
get PEM formatted certificate signing request (CSR/PKCS#10)
This method is to a get CSR PEM string
 
setByParam(params)
set parameter
This method will set parameter to this object.
 
sign()
sign CertificationRequest and set signature value internally
This method self-signs CertificateRequestInfo with a subject's private key and set signature value internally.
Methods borrowed from class KJUR.asn1.ASN1Object:
getEncodedHex, getLengthHexFromValue, getValueHex, tohex
Class Detail
KJUR.asn1.csr.CertificationRequest(params)
ASN.1 CertificationRequest structure class This class provides CertificateRequestInfo ASN.1 structure defined in RFC 2986 4.2.
CertificationRequest ::= SEQUENCE {
  certificationRequestInfo CertificationRequestInfo,
  signatureAlgorithm       AlgorithmIdentifier{{ SignatureAlgorithms }},
  signature                BIT STRING }
CertificationRequestInfo ::= SEQUENCE {
  version       INTEGER { v1(0) } (v1,...),
  subject       Name,
  subjectPKInfo SubjectPublicKeyInfo{{ PKInfoAlgorithms }},
  attributes    [0] Attributes{{ CRIAttributes }} }
Argument "params" JSON object can have following keys:
  • {Array}subject - parameter to be passed to KJUR.asn1.x509.X500Name
  • {Object}sbjpubkey - PEM string or key object to be passed to KEYUTIL.getKey
  • {Array}extreq - array of certificate extension parameters
  • {String}sigalg - signature algorithm name (ex. SHA256withRSA)
  • {Object}sbjprvkey - PEM string or key object to be passed to KEYUTIL.getKey (OPTION)
  • {String}sighex - hexadecimal string of signature value. When this is not defined and sbjprvkey is specified, sighex will be set automatically during getEncodedHex() is called. (OPTION)

CAUTION: Argument "params" JSON value format have been changed without backward compatibility since jsrsasign 9.0.0 asn1csr 2.0.0.
// sign by private key
csr = new KJUR.asn1.csr.CertificationRequest({
  subject: {str:"/C=US/O=Test"},
  sbjpubkey: "-----BEGIN PUBLIC KEY...",
  extreq: [{extname:"subjectAltName",array:[{dns:"example.com"}]}]
  sigalg: "SHA256withRSA",
  sbjprvkey: "-----BEGIN PRIVATE KEY..."
});
pem = csr.getPEM(); // signed with sbjprvkey automatically

// or specifying signature value
csr = new KJUR.asn1.csr.CertificationRequest({
  subject: {str:"/C=US/O=Test"},
  sbjpubkey: "-----BEGIN PUBLIC KEY...",
  extreq: [{extname:"subjectAltName",array:[{dns:"example.com"}]}]
  sigalg: "SHA256withRSA",
  sighex: "1234abcd..."
});
pem = csr.getPEM();
Parameters:
{Array} params
associative array of parameters
Since:
jsrsasign 4.9.0 asn1csr 1.0.0
See:
KJUR.asn1.csr.CertificationRequestInfo
Method Detail
getPEM()
get PEM formatted certificate signing request (CSR/PKCS#10)
This method is to a get CSR PEM string
csr = new KJUR.asn1.csr.CertificationRequest({
  subject: "/C=JP/O=Test",
  sbjpubkey: ...
});
csr.getPEM() → "-----BEGIN CERTIFICATE REQUEST..."
Returns:
PEM formatted string of CSR/PKCS#10

setByParam(params)
set parameter
This method will set parameter to this object.
csr = new KJUR.asn1.x509.CertificationRequest();
csr.setByParam({
  subject: {str: "/C=JP/O=Test"},
  ...
});
Parameters:
params
{Array} JSON object of CSR parameters
Since:
jsrsasign 9.0.0 asn1csr 2.0.0

sign()
sign CertificationRequest and set signature value internally
This method self-signs CertificateRequestInfo with a subject's private key and set signature value internally.
csr = new KJUR.asn1.csr.CertificationRequest({
  subject: "/C=JP/O=Test",
  sbjpubkey: ...
});
csr.sign();

© 2012-2023 Kenji Urushima, All rights reserved
Documentation generated by JsDoc Toolkit 2.4.0