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

Constructors

Properties

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

Name of the class

Accessors

  • get className(): string
  • Returns string

Methods

  • 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>

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

    Returns

    ASN.1 object

    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

  • Parameters

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

    Returns string

  • Compare values with default values for all class members

    Returns

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

    Parameters

    • memberName: string

      String name for a class member

    • memberValue: any

      Value to compare with default value

    Returns boolean

  • Creates PKI object from the raw data

    Returns

    Initialized and filled current class object

    Type Parameters

    Parameters

    • this: PkiObjectConstructor<T>
    • raw: BufferSource

      ASN.1 encoded raw data

    Returns T

Generated using TypeDoc