---
name: "libressl-X509_REQ_add_extensions"
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-X509_REQ_add_extensions"
---

# libressl-X509\_REQ\_add\_extensions(3)

extensions in certification requests

## NAME

**X509\_REQ\_add\_extensions**, **X509\_REQ\_add\_extensions\_nid**, **X509\_REQ\_get\_extensions**, **X509\_REQ\_extension\_nid** – extensions in certification requests

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

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

*int*\

**X509\_REQ\_add\_extensions**(*X509\_REQ \*req*, *STACK\_OF(X509\_EXTENSION) \*extensions*);

*int*\

**X509\_REQ\_add\_extensions\_nid**(*X509\_REQ \*req*, *STACK\_OF(X509\_EXTENSION) \*extensions*, *int nid*);

*STACK\_OF(X509\_EXTENSION)* *\**\

**X509\_REQ\_get\_extensions**(*X509\_REQ \*req*);

*int*\

**X509\_REQ\_extension\_nid**(*int nid*);

## DESCRIPTION

**X509\_REQ\_add\_extensions**() encodes the array of *extensions* using i2d\_X509\_EXTENSIONS(3) and adds a new X.501 Attribute object of the type NID\_ext\_req to *req* using the equivalent of X509\_ATTRIBUTE\_create\_by\_NID(3) with a *type* of V\_ASN1\_SEQUENCE.

**X509\_REQ\_add\_extensions\_nid**() is identical except that the specified *nid* is used as the X.501 Attribute type instead of NID\_ext\_req.

**X509\_REQ\_get\_extensions**() retrieves the first value of the first X.501 Attribute of appropriate type. By default, the attribute types NID\_ext\_req and NID\_ms\_ext\_req are considered appropriate.

**X509\_REQ\_extension\_nid**() checks whether **X509\_REQ\_get\_extensions**() regards the *nid* argument as a type appropriate for storing extensions.

## RETURN VALUES

**X509\_REQ\_add\_extensions**() and **X509\_REQ\_add\_extensions\_nid**() returns 1 for success or 0 for failure.

**X509\_REQ\_get\_extensions**() returns a newly allocated array of ASN.1 *Extension* objects or NULL if *req* is NULL, does not contain *CertificationRequestInfo*, contains no attribute of an appropriate type, or if decoding or memory allocation fails.

**X509\_REQ\_extension\_nid**() returns 1 if *nid* is considered appropriate or 0 otherwise.

## SEE ALSO

d2i\_X509\_EXTENSION(3), STACK\_OF(3), X509\_EXTENSION\_new(3), X509\_REQ\_new(3), X509V3\_extensions\_print(3)

## HISTORY

These functions first appeared in OpenSSL 0.9.5 and have been available since OpenBSD 2.7.
