OCSPResponse
Represents an OCSP response described in RFC6960 Section 4.2
Examples
Section titled “Examples”The following example demonstrates how to verify OCSP response
const asnOcspResp = asn1js.fromBER(ocspRespRaw);const ocspResp = new pkijs.OCSPResponse({ schema: asnOcspResp.result });
if (!ocspResp.responseBytes) { throw new Error("No \"ResponseBytes\" in the OCSP Response - nothing to verify");}
const asnOcspRespBasic = asn1js.fromBER(ocspResp.responseBytes.response.valueBlock.valueHex);const ocspBasicResp = new pkijs.BasicOCSPResponse({ schema: asnOcspRespBasic.result });const ok = await ocspBasicResp.verify({ trustedCerts: [cert] });The following example demonstrates how to create OCSP response
const ocspBasicResp = new pkijs.BasicOCSPResponse();
// Create specific TST info structure to signocspBasicResp.tbsResponseData.responderID = issuerCert.subject;ocspBasicResp.tbsResponseData.producedAt = new Date();
const certID = new pkijs.CertID();await certID.createForCertificate(cert, { hashAlgorithm: "SHA-256", issuerCertificate: issuerCert,});const response = new pkijs.SingleResponse({ certID,});response.certStatus = new asn1js.Primitive({ idBlock: { tagClass: 3, // CONTEXT-SPECIFIC tagNumber: 0 // [0] }, lenBlockLength: 1 // The length contains one byte 0x00}); // status - successresponse.thisUpdate = new Date();
ocspBasicResp.tbsResponseData.responses.push(response);
// Add certificates for chain OCSP response validationocspBasicResp.certs = [issuerCert];
await ocspBasicResp.sign(keys.privateKey, "SHA-256");
// Finally create completed OCSP response structureconst ocspBasicRespRaw = ocspBasicResp.toSchema().toBER(false);
const ocspResp = new pkijs.OCSPResponse({ responseStatus: new asn1js.Enumerated({ value: 0 }), // success responseBytes: new pkijs.ResponseBytes({ responseType: pkijs.id_PKIX_OCSP_Basic, response: new asn1js.OctetString({ valueHex: ocspBasicRespRaw }), }),});
const ocspRespRaw = ocspResp.toSchema().toBER();Extends
Section titled “Extends”Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new OCSPResponse(
parameters?):OCSPResponse
Initializes a new instance of the OCSPResponse class
Parameters
Section titled “Parameters”parameters?
Section titled “parameters?”Initialization parameters
Returns
Section titled “Returns”OCSPResponse
Overrides
Section titled “Overrides”Properties
Section titled “Properties”responseBytes?
Section titled “responseBytes?”
optionalresponseBytes?:ResponseBytes
Implementation of
Section titled “Implementation of”responseStatus
Section titled “responseStatus”responseStatus:
Enumerated
Implementation of
Section titled “Implementation of”CLASS_NAME
Section titled “CLASS_NAME”
staticCLASS_NAME:string="OCSPResponse"
Name of the class
Overrides
Section titled “Overrides”Accessors
Section titled “Accessors”className
Section titled “className”Get Signature
Section titled “Get Signature”get className():
string
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”fromSchema()
Section titled “fromSchema()”fromSchema(
schema):void
Converts parsed ASN.1 object into current class
Parameters
Section titled “Parameters”schema
Section titled “schema”any
ASN.1 schema
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”getCertificateStatus()
Section titled “getCertificateStatus()”getCertificateStatus(
certificate,issuerCertificate,crypto?):Promise<CertificateStatus>
Get OCSP response status for specific certificate
Parameters
Section titled “Parameters”certificate
Section titled “certificate”issuerCertificate
Section titled “issuerCertificate”crypto?
Section titled “crypto?”ICryptoEngine = ...
Crypto engine
Returns
Section titled “Returns”Promise<CertificateStatus>
sign()
Section titled “sign()”sign(
privateKey,hashAlgorithm?,crypto?):Promise<void>
Make a signature for current OCSP Response
Parameters
Section titled “Parameters”privateKey
Section titled “privateKey”CryptoKey
Private key for “subjectPublicKeyInfo” structure
hashAlgorithm?
Section titled “hashAlgorithm?”string
Hashing algorithm. Default SHA-1
crypto?
Section titled “crypto?”ICryptoEngine = ...
Returns
Section titled “Returns”Promise<void>
toJSON()
Section titled “toJSON()”toJSON():
OCSPResponseJson
Converts the class to JSON object
Returns
Section titled “Returns”JSON object
Overrides
Section titled “Overrides”toSchema()
Section titled “toSchema()”toSchema():
Sequence
Converts current object to ASN.1 object and sets correct values
Returns
Section titled “Returns”Sequence
ASN.1 object
Overrides
Section titled “Overrides”toString()
Section titled “toString()”toString(
encoding?):string
Parameters
Section titled “Parameters”encoding?
Section titled “encoding?”"hex" | "base64" | "base64url" = "hex"
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”verify()
Section titled “verify()”verify(
issuerCertificate?,crypto?,params?):Promise<boolean>
Verify current OCSP Response
Parameters
Section titled “Parameters”issuerCertificate?
Section titled “issuerCertificate?”Certificate | null = null
In order to decrease size of resp issuer cert could be omitted. In such case you need manually provide it.
crypto?
Section titled “crypto?”ICryptoEngine = ...
Crypto engine
params?
Section titled “params?”BasicOCSPResponseVerifyParams = {}
Parameters for the verification of the basic response, such as trusted certificates and the validation policy
Returns
Section titled “Returns”Promise<boolean>
blockName()
Section titled “blockName()”
staticblockName():string
Returns block name
Returns
Section titled “Returns”string
Returns string block name
Inherited from
Section titled “Inherited from”compareWithDefault()
Section titled “compareWithDefault()”
staticcompareWithDefault(memberName,memberValue):boolean
Compare values with default values for all class members
Parameters
Section titled “Parameters”memberName
Section titled “memberName”string
String name for a class member
memberValue
Section titled “memberValue”any
Value to compare with default value
Returns
Section titled “Returns”boolean
defaultValues()
Section titled “defaultValues()”Call Signature
Section titled “Call Signature”
staticdefaultValues(memberName):Enumerated
Returns default values for all class members
Parameters
Section titled “Parameters”memberName
Section titled “memberName”"responseStatus"
String name for a class member
Returns
Section titled “Returns”Enumerated
Default value
Overrides
Section titled “Overrides”Call Signature
Section titled “Call Signature”
staticdefaultValues(memberName):ResponseBytes
Returns default values for all class members
Parameters
Section titled “Parameters”memberName
Section titled “memberName”"responseBytes"
String name for a class member
Returns
Section titled “Returns”Default value
Overrides
Section titled “Overrides”PkiObject.defaultValues
fromBER()
Section titled “fromBER()”
staticfromBER<T>(this,raw):T
Creates PKI object from the raw data
Type Parameters
Section titled “Type Parameters”T extends PkiObject
Parameters
Section titled “Parameters”PkiObjectConstructor<T>
BufferSource
ASN.1 encoded raw data
Returns
Section titled “Returns”T
Initialized and filled current class object
Inherited from
Section titled “Inherited from”schema()
Section titled “schema()”
staticschema(parameters?):any
Returns value of pre-defined ASN.1 schema for current class
Parameters
Section titled “Parameters”parameters?
Section titled “parameters?”SchemaParameters<{ responseBytes?: ResponseBytesSchema; responseStatus?: string; }> = {}
Input parameters for the schema
Returns
Section titled “Returns”any
ASN.1 schema object