# getEncodedOcsp

## Content

# Function: getEncodedOcsp()

```ts
function getEncodedOcsp(
   certPem, 
   issuerPem, 
   ocspUrl?, 
   options?): Promise<ArrayBuffer>;
```

Retrieves a DER-encoded OCSP response for the given certificate and its issuer.

If `ocspUrl` is not provided, the function attempts to extract the OCSP responder
URL from the Authority Information Access (AIA) extension of the `certPem`.
A custom OCSP request handler can be supplied via `fetchOcsp`.

## Parameters

### certPem

`string`

PEM-encoded end-entity certificate to check.

### issuerPem

`string`

PEM-encoded issuer (CA) certificate.

### ocspUrl?

`string`

Optional OCSP responder URL. If not provided, it will be
resolved from the certificate's AIA extension.

### options?

[`ExternalResourcesOptions`](../interfaces/ExternalResourcesOptions)

The options used to execute OCSP request.

## Returns

`Promise`&lt;`ArrayBuffer`&gt;

DER-encoded OCSP response as an ArrayBuffer,
or `null` if the response could not be obtained or an error occurs.

## Throws

If the certificates are invalid or the OCSP request fails unexpectedly.
