Skip to main content

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

OCSPRequest

Overrides

PkiObject.constructor

Properties

optionalSignature?

optional optionalSignature: Signature

Implementation of

IOCSPRequest.optionalSignature


tbsRequest

tbsRequest: TBSRequest

Implementation of

IOCSPRequest.tbsRequest


CLASS_NAME

static CLASS_NAME: string = "OCSPRequest"

Name of the class

Overrides

PkiObject.CLASS_NAME

Accessors

className

get className(): string

Returns

string

Inherited from

PkiObject.className

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

PkiObject.fromSchema


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

OCSPRequestJson

JSON object

Overrides

PkiObject.toJSON


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

PkiObject.toSchema


toString()

toString(encoding): string

Parameters

encoding: "base64" | "base64url" | "hex" = "hex"

Returns

string

Inherited from

PkiObject.toString


verify()

verify(): void

Returns

void


blockName()

static blockName(): string

Returns block name

Returns

string

Returns string block name

Inherited from

PkiObject.blockName


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

TBSRequest

Default value

Overrides

PkiObject.defaultValues

defaultValues(memberName)

static defaultValues(memberName): Signature

Returns default values for all class members

Parameters

memberName: "optionalSignature"

String name for a class member

Returns

Signature

Default value

Overrides

PkiObject.defaultValues


fromBER()

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

Creates PKI object from the raw data

Type Parameters

T extends PkiObject

Parameters

this: PkiObjectConstructor<T>

raw: BufferSource

ASN.1 encoded raw data

Returns

T

Initialized and filled current class object

Inherited from

PkiObject.fromBER


schema()

static schema(parameters): any

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

Parameters

parameters: SchemaParameters<object> = {}

Input parameters for the schema

Returns

any

ASN.1 schema object

Overrides

PkiObject.schema