---
name: "libressl-OCSP_REQUEST_new"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-OCSP_REQUEST_new"
---

# libressl-OCSP\_REQUEST\_new(3)

OCSP request functions

## NAME

**OCSP\_REQUEST\_new**, **OCSP\_REQUEST\_free**, **OCSP\_SIGNATURE\_new**, **OCSP\_SIGNATURE\_free**, **OCSP\_REQINFO\_new**, **OCSP\_REQINFO\_free**, **OCSP\_ONEREQ\_new**, **OCSP\_ONEREQ\_free**, **OCSP\_request\_add0\_id**, **OCSP\_request\_sign**, **OCSP\_request\_add1\_cert**, **OCSP\_request\_onereq\_count**, **OCSP\_request\_onereq\_get0** – OCSP request functions

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/ocsp.h\>**

*OCSP\_REQUEST* *\**\

**OCSP\_REQUEST\_new**(*void*);

*void*\

**OCSP\_REQUEST\_free**(*OCSP\_REQUEST \*req*);

*OCSP\_SIGNATURE* *\**\

**OCSP\_SIGNATURE\_new**(*void*);

*void*\

**OCSP\_SIGNATURE\_free**(*OCSP\_SIGNATURE \*signature*);

*OCSP\_REQINFO* *\**\

**OCSP\_REQINFO\_new**(*void*);

*void*\

**OCSP\_REQINFO\_free**(*OCSP\_REQINFO \*reqinfo*);

*OCSP\_ONEREQ* *\**\

**OCSP\_ONEREQ\_new**(*void*);

*void*\

**OCSP\_ONEREQ\_free**(*OCSP\_ONEREQ \*onereq*);

*OCSP\_ONEREQ* *\**\

**OCSP\_request\_add0\_id**(*OCSP\_REQUEST \*req*, *OCSP\_CERTID \*cid*);

*int*\

**OCSP\_request\_sign**(*OCSP\_REQUEST \*req*, *X509 \*signer*, *EVP\_PKEY \*key*, *const EVP\_MD \*dgst*, *STACK\_OF(X509) \*certs*, *unsigned long flags*);

*int*\

**OCSP\_request\_add1\_cert**(*OCSP\_REQUEST \*req*, *X509 \*cert*);

*int*\

**OCSP\_request\_onereq\_count**(*OCSP\_REQUEST \*req*);

*OCSP\_ONEREQ* *\**\

**OCSP\_request\_onereq\_get0**(*OCSP\_REQUEST \*req*, *int i*);

## DESCRIPTION

**OCSP\_REQUEST\_new**() allocates and initializes an empty *OCSP\_REQUEST* object, representing an ASN.1 *OCSPRequest* structure defined in RFC 6960. **OCSP\_REQUEST\_free**() frees *req*.

**OCSP\_SIGNATURE\_new**() allocates and initializes an empty *OCSP\_SIGNATURE* object, representing an ASN.1 *Signature* structure defined in RFC 6960. Such an object is used inside *OCSP\_REQUEST*. **OCSP\_SIGNATURE\_free**() frees *signature*.

**OCSP\_REQINFO\_new**() allocates and initializes an empty *OCSP\_REQINFO* object, representing an ASN.1 *TBSRequest* structure defined in RFC 6960. Such an object is used inside *OCSP\_REQUEST*. It asks about the validity of one or more certificates. **OCSP\_REQINFO\_free**() frees *reqinfo*.

**OCSP\_ONEREQ\_new**() allocates and initializes an empty *OCSP\_ONEREQ* object, representing an ASN.1 *Request* structure defined in RFC 6960. Such objects are used inside *OCSP\_REQINFO*. Each one asks about the validity of one certificate. **OCSP\_ONEREQ\_free**() frees *onereq*.

**OCSP\_request\_add0\_id**() adds certificate ID *cid* to *req*. It returns the *OCSP\_ONEREQ* object added so an application can add additional extensions to the request. The *cid* parameter must not be freed up after the operation.

**OCSP\_request\_sign**() signs OCSP request *req* using certificate *signer*, private key *key*, digest *dgst*, and additional certificates *certs*. If the *flags* option OCSP\_NOCERTS is set, then no certificates will be included in the request.

**OCSP\_request\_add1\_cert**() adds certificate *cert* to request *req*. The application is responsible for freeing up *cert* after use.

**OCSP\_request\_onereq\_count**() returns the total number of *OCSP\_ONEREQ* objects in *req*.

**OCSP\_request\_onereq\_get0**() returns an internal pointer to the *OCSP\_ONEREQ* contained in *req* of index *i*. The index value *i* runs from 0 to **OCSP\_request\_onereq\_count**(*req*, *No*, *-*, *1*).

**OCSP\_request\_onereq\_count**() and **OCSP\_request\_onereq\_get0**() are mainly used by OCSP responders.

## RETURN VALUES

**OCSP\_REQUEST\_new**(), **OCSP\_SIGNATURE\_new**(), **OCSP\_REQINFO\_new**(), and **OCSP\_ONEREQ\_new**() return an empty *OCSP\_REQUEST*, *OCSP\_SIGNATURE*, *OCSP\_REQINFO*, or *OCSP\_ONEREQ* object, respectively, or NULL if an error occurred.

**OCSP\_request\_add0\_id**() returns the *OCSP\_ONEREQ* object containing *cid* or NULL if an error occurred.

**OCSP\_request\_sign**() and **OCSP\_request\_add1\_cert**() return 1 for success or 0 for failure.

**OCSP\_request\_onereq\_count**() returns the total number of *OCSP\_ONEREQ* objects in *req*.

**OCSP\_request\_onereq\_get0**() returns a pointer to an *OCSP\_ONEREQ* object or NULL if the index value is out of range.

## EXAMPLES

Create an *OCSP\_REQUEST* object for certificate *cert* with issuer *issuer*:

```
OCSP_REQUEST *req;
OCSP_ID *cid;
req = OCSP_REQUEST_new();
if (req == NULL)
	/* error */
cid = OCSP_cert_to_id(EVP_sha1(), cert, issuer);
if (cid == NULL)
	/* error */
if (OCSP_REQUEST_add0_id(req, cid) == NULL)
	/* error */
 /* Do something with req, e.g. query responder */
OCSP_REQUEST_free(req);
```

## SEE ALSO

ACCESS\_DESCRIPTION\_new(3), [crypto(3)](/crypto/3.md), d2i\_OCSP\_REQUEST(3), d2i\_OCSP\_RESPONSE(3), EVP\_DigestInit(3), OCSP\_cert\_to\_id(3), OCSP\_CRLID\_new(3), OCSP\_request\_add1\_nonce(3), OCSP\_resp\_find\_status(3), OCSP\_response\_status(3), OCSP\_sendreq\_new(3), OCSP\_SERVICELOC\_new(3), X509\_ocspid\_print(3)

## STANDARDS

RFC 6960: X.509 Internet Public Key Infrastructure Online Certificate Status Protocol, section 4.1: Request Syntax

## HISTORY

These functions first appeared in OpenSSL 0.9.7 and have been available since OpenBSD 3.2.
