Skip to content
PKIjsPKIjsPKIjsv4.0.1

OCSPRequest

Represents an OCSP request described in RFC6960 Section 4.1

The following example demonstrates how to create OCSP request

// 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();

new OCSPRequest(parameters?): OCSPRequest

Initializes a new instance of the OCSPRequest class

OCSPRequestParameters = {}

Initialization parameters

OCSPRequest

PkiObject.constructor

optional optionalSignature?: Signature

IOCSPRequest.optionalSignature


tbsRequest: TBSRequest

IOCSPRequest.tbsRequest


static CLASS_NAME: string = "OCSPRequest"

Name of the class

PkiObject.CLASS_NAME

get className(): string

string

PkiObject.className

createForCertificate(certificate, parameters, crypto?): Promise<void>

Making OCSP Request for specific certificate

Certificate

Certificate making OCSP Request for

CertIDCreateParams

Additional parameters

ICryptoEngine = ...

Crypto engine

Promise<void>


fromSchema(schema): void

Converts parsed ASN.1 object into current class

any

ASN.1 schema

void

PkiObject.fromSchema


sign(privateKey, hashAlgorithm?, crypto?): Promise<void>

Make signature for current OCSP Request

CryptoKey

Private key for “subjectPublicKeyInfo” structure

string = "SHA-1"

Hashing algorithm. Default SHA-1

ICryptoEngine = ...

Crypto engine

Promise<void>


toJSON(): OCSPRequestJson

Converts the class to JSON object

OCSPRequestJson

JSON object

PkiObject.toJSON


toSchema(encodeFlag?): Sequence

Converts current object to ASN.1 object and sets correct values

boolean = false

If param equal to false then creates schema via decoding stored value. In other case creates schema via assembling from cached parts

Sequence

ASN.1 object

PkiObject.toSchema


toString(encoding?): string

"hex" | "base64" | "base64url" = "hex"

string

PkiObject.toString


verify(): void

void


static blockName(): string

Returns block name

string

Returns string block name

PkiObject.blockName


static compareWithDefault(memberName, memberValue): boolean

Compare values with default values for all class members

string

String name for a class member

any

Value to compare with default value

boolean

Returns true if memberValue is equal to default value for selected class member


static defaultValues(memberName): TBSRequest

Returns default values for all class members

"tbsRequest"

String name for a class member

TBSRequest

Default value

PkiObject.defaultValues

static defaultValues(memberName): Signature

Returns default values for all class members

"optionalSignature"

String name for a class member

Signature

Default value

PkiObject.defaultValues


static fromBER<T>(this, raw): T

Creates PKI object from the raw data

T extends PkiObject

PkiObjectConstructor<T>

BufferSource

ASN.1 encoded raw data

T

Initialized and filled current class object

PkiObject.fromBER


static schema(parameters?): any

Returns value of pre-defined ASN.1 schema for current class

SchemaParameters<{ optionalSignature?: SignatureSchema; tbsRequest?: TBSRequestSchema; }> = {}

Input parameters for the schema

any

ASN.1 schema object

PkiObject.schema