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

# libressl-X509\_REQ\_add1\_attr(3)

X.501 Attributes of PKCS#10 certification requests

## NAME

**X509\_REQ\_add1\_attr**, **X509\_REQ\_add1\_attr\_by\_OBJ**, **X509\_REQ\_add1\_attr\_by\_NID**, **X509\_REQ\_add1\_attr\_by\_txt**, **X509\_REQ\_delete\_attr**, **X509\_REQ\_get\_attr**, **X509\_REQ\_get\_attr\_count**, **X509\_REQ\_get\_attr\_by\_OBJ**, **X509\_REQ\_get\_attr\_by\_NID** – X.501 Attributes of PKCS#10 certification requests

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

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

*int*\

**X509\_REQ\_add1\_attr**(*X509\_REQ \*req*, *X509\_ATTRIBUTE \*attr*);

*int*\

**X509\_REQ\_add1\_attr\_by\_OBJ**(*X509\_REQ \*req*, *const ASN1\_OBJECT \*obj*, *int type*, *const unsigned char \*data*, *int len*);

*int*\

**X509\_REQ\_add1\_attr\_by\_NID**(*X509\_REQ \*req*, *int nid*, *int type*, *const unsigned char \*data*, *int len*);

*int*\

**X509\_REQ\_add1\_attr\_by\_txt**(*X509\_REQ \*req*, *const char \*name*, *int type*, *const unsigned char \*data*, *int len*);

*X509\_ATTRIBUTE* *\**\

**X509\_REQ\_delete\_attr**(*X509\_REQ \*req*, *int index*);

*X509\_ATTRIBUTE* *\**\

**X509\_REQ\_get\_attr**(*const X509\_REQ \*req*, *int index*);

*int*\

**X509\_REQ\_get\_attr\_count**(*const X509\_REQ \*req*);

*int*\

**X509\_REQ\_get\_attr\_by\_OBJ**(*const X509\_REQ \*req*, *const ASN1\_OBJECT \*obj*, *int start\_after*);

*int*\

**X509\_REQ\_get\_attr\_by\_NID**(*const X509\_REQ \*req*, *int nid*, *int start\_after*);

## DESCRIPTION

These functions support associating an array of X.501 Attributes with a PKCS#10 certification request.

**X509\_REQ\_add1\_attr**() appends a deep copy of the *attr*, allocating a new array if necessary.

**X509\_REQ\_add1\_attr\_by\_OBJ**(), **X509\_REQ\_add1\_attr\_by\_NID**(), and **X509\_REQ\_add1\_attr\_by\_txt**() create a new X.501 Attribute object using X509\_ATTRIBUTE\_create\_by\_OBJ(3), X509\_ATTRIBUTE\_create\_by\_NID(3), or X509\_ATTRIBUTE\_create\_by\_txt(3), respectively, allocating a new array if necessary.

**X509\_REQ\_delete\_attr**() deletes the attribute with the zero-based *index*.

**X509\_REQ\_get\_attr**() returns the attribute with the zero-based *index*.

**X509\_REQ\_get\_attr\_count**() returns the number of attributes currently associated with *req*.

**X509\_REQ\_get\_attr\_by\_OBJ**() and **X509\_REQ\_get\_attr\_by\_NID**() search for an attribute of the type *obj* or *nid*.

## RETURN VALUES

**X509\_REQ\_add1\_attr**(), **X509\_REQ\_add1\_attr\_by\_OBJ**(), **X509\_REQ\_add1\_attr\_by\_NID**(), and **X509\_REQ\_add1\_attr\_by\_txt**() return 1 for success or 0 for failure.

**X509\_REQ\_delete\_attr**() and **X509\_REQ\_get\_attr**() return the deleted or requested attribute or NULL if the requested index is negative or greater than or equal to the current number of attributes associated with *req*.

**X509\_REQ\_get\_attr\_count**() returns the current number of attributes.

**X509\_REQ\_get\_attr\_by\_OBJ**() and **X509\_REQ\_get\_attr\_by\_NID**() return the index of the first attribute that has an index greater than *start\_after* and a type matching *obj* or *nid*, respectively, or -1 on failure. In addition, **X509\_REQ\_get\_attr\_by\_NID**() returns -2 if OBJ\_nid2obj(3) fails on the requested *nid*.

## SEE ALSO

OBJ\_nid2obj(3), X509\_ATTRIBUTE\_create\_by\_OBJ(3), X509\_ATTRIBUTE\_new(3), X509\_REQ\_new(3)

## HISTORY

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