OCSPRequest
Represents an OCSP request described in RFC6960 Section 4.1
Example
// Create OCSP request
const ocspReq = new pkijs.OCSPRequest();
ocspReq.tbsRequest.requestorName = new pkijs.GeneralName({
type: 4,
value: cert.subject,
});
await ocspReq.createForCertificate(cert, {
hashAlgorithm: "SHA-256",
issuerCertificate: issuerCert,
});
const nonce = pkijs.getRandomValues(new Uint8Array(10));
ocspReq.tbsRequest.requestExtensions = [
new pkijs.Extension({
extnID: "1.3.6.1.5.5.7.48.1.2", // nonce
extnValue: new asn1js.OctetString({ valueHex: nonce.buffer }).toBER(),
})
];
// Encode OCSP request
const ocspReqRaw = ocspReq.toSchema(true).toBER();
Extends
Implements
Constructors
new OCSPRequest()
new OCSPRequest(
parameters
):OCSPRequest
Initializes a new instance of the OCSPRequest class
Parameters
• parameters: OCSPRequestParameters
= {}
Initialization parameters
Returns
Overrides
Properties
optionalSignature?
optional
optionalSignature:Signature
Implementation of
IOCSPRequest
.optionalSignature
tbsRequest
tbsRequest:
TBSRequest
Implementation of
CLASS_NAME
static
CLASS_NAME:string
="OCSPRequest"
Name of the class
Overrides
Accessors
className
get
className():string
Returns
string
Inherited from
Methods
createForCertificate()
createForCertificate(
certificate
,parameters
,crypto
):Promise
<void
>
Making OCSP Request for specific certificate
Parameters
• certificate: Certificate
Certificate making OCSP Request for
• parameters: CertIDCreateParams
Additional parameters
• crypto: ICryptoEngine
= ...
Crypto engine
Returns
Promise
<void
>
fromSchema()
fromSchema(
schema
):void
Converts parsed ASN.1 object into current class
Parameters
• schema: any
ASN.1 schema
Returns
void
Overrides
sign()
sign(
privateKey
,hashAlgorithm
,crypto
):Promise
<void
>
Make signature for current OCSP Request
Parameters
• privateKey: CryptoKey
Private key for "subjectPublicKeyInfo" structure
• hashAlgorithm: string
= "SHA-1"
Hashing algorithm. Default SHA-1
• crypto: ICryptoEngine
= ...
Crypto engine
Returns
Promise
<void
>
toJSON()
toJSON():
OCSPRequestJson
Converts the class to JSON object
Returns
JSON object
Overrides
toSchema()
toSchema(
encodeFlag
):Sequence
Converts current object to ASN.1 object and sets correct values
Parameters
• encodeFlag: boolean
= false
If param equal to false
then creates schema via decoding stored value. In other case creates schema via assembling from cached parts
Returns
Sequence
ASN.1 object
Overrides
toString()
toString(
encoding
):string
Parameters
• encoding: "base64"
| "base64url"
| "hex"
= "hex"
Returns
string
Inherited from
verify()
verify():
void
Returns
void
blockName()
static
blockName():string
Returns block name
Returns
string
Returns string block name
Inherited from
compareWithDefault()
static
compareWithDefault(memberName
,memberValue
):boolean
Compare values with default values for all class members
Parameters
• memberName: string
String name for a class member
• memberValue: any
Value to compare with default value
Returns
boolean
Returns true
if memberValue
is equal to default value for selected class member
defaultValues()
defaultValues(memberName)
static
defaultValues(memberName
):TBSRequest
Returns default values for all class members
Parameters
• memberName: "tbsRequest"
String name for a class member
Returns
Default value
Overrides
defaultValues(memberName)
static
defaultValues(memberName
):Signature
Returns default values for all class members