Options
All
  • Public
  • Public/Protected
  • All
Menu

Class OCSPRequest

Represents an OCSP request described in RFC6960 Section 4.1

example

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

Hierarchy

Implements

Index

Constructors

Properties

optionalSignature?: Signature
tbsRequest: TBSRequest
CLASS_NAME: string = "OCSPRequest"

Name of the class

Accessors

  • get className(): string

Methods

  • fromSchema(schema: any): void
  • sign(privateKey: CryptoKey, hashAlgorithm?: string, crypto?: ICryptoEngine): 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>

  • toSchema(encodeFlag?: boolean): Sequence
  • toString(encoding?: "base64" | "base64url" | "hex"): string
  • verify(): void
  • blockName(): string
  • compareWithDefault(memberName: string, memberValue: any): 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(memberName: "tbsRequest"): TBSRequest
  • defaultValues(memberName: "optionalSignature"): Signature
  • fromBER<T>(this: PkiObjectConstructor<T>, raw: BufferSource): T
  • Creates PKI object from the raw data

    Type Parameters

    Parameters

    • this: PkiObjectConstructor<T>
    • raw: BufferSource

      ASN.1 encoded raw data

    Returns T

    Initialized and filled current class object

Generated using TypeDoc