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

# libressl-X509\_NAME\_ENTRY\_get\_object(3)

X.501 relative distinguished name

## NAME

**X509\_NAME\_ENTRY\_new**, **X509\_NAME\_ENTRY\_free**, **X509\_NAME\_ENTRY\_get\_object**, **X509\_NAME\_ENTRY\_get\_data**, **X509\_NAME\_ENTRY\_set**, **X509\_NAME\_ENTRY\_set\_object**, **X509\_NAME\_ENTRY\_set\_data**, **X509\_NAME\_ENTRY\_create\_by\_txt**, **X509\_NAME\_ENTRY\_create\_by\_NID**, **X509\_NAME\_ENTRY\_create\_by\_OBJ** – X.501 relative distinguished name

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

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

*X509\_NAME\_ENTRY* *\**\

**X509\_NAME\_ENTRY\_new**(*void*);

*void*\

**X509\_NAME\_ENTRY\_free**(*X509\_NAME\_ENTRY\* ne*);

*ASN1\_OBJECT* *\**\

**X509\_NAME\_ENTRY\_get\_object**(*const X509\_NAME\_ENTRY \*ne*);

*ASN1\_STRING* *\**\

**X509\_NAME\_ENTRY\_get\_data**(*const X509\_NAME\_ENTRY \*ne*);

*int*\

**X509\_NAME\_ENTRY\_set**(*const X509\_NAME\_ENTRY \*ne*);

*int*\

**X509\_NAME\_ENTRY\_set\_object**(*X509\_NAME\_ENTRY \*ne*, *const ASN1\_OBJECT \*obj*);

*int*\

**X509\_NAME\_ENTRY\_set\_data**(*X509\_NAME\_ENTRY \*ne*, *int type*, *const unsigned char \*bytes*, *int len*);

*X509\_NAME\_ENTRY* *\**\

**X509\_NAME\_ENTRY\_create\_by\_txt**(*X509\_NAME\_ENTRY \*\*ne*, *const char \*field*, *int type*, *const unsigned char \*bytes*, *int len*);

*X509\_NAME\_ENTRY* *\**\

**X509\_NAME\_ENTRY\_create\_by\_NID**(*X509\_NAME\_ENTRY \*\*ne*, *int nid*, *int type*, *const unsigned char \*bytes*, *int len*);

*X509\_NAME\_ENTRY* *\**\

**X509\_NAME\_ENTRY\_create\_by\_OBJ**(*X509\_NAME\_ENTRY \*\*ne*, *const ASN1\_OBJECT \*obj*, *int type*, *const unsigned char \*bytes*, *int len*);

## DESCRIPTION

An X.501 *RelativeDistinguishedName* is an ordered set of field type and value pairs. It is the building block for constructing X.501 *Name* objects. The *X509\_NAME\_ENTRY* object stores one such pair, containing one field type and one value.

*X509\_NAME\_ENTRY* objects are intended for use by the *X509\_NAME* objects documented in X509\_NAME\_new(3). Since part of the information about how several *X509\_NAME\_ENTRY* objects combine to form an X.501 *Name* is stored in the individual *X509\_NAME\_ENTRY* objects rather than in the *X509\_NAME* object, any given *X509\_NAME\_ENTRY* object can only be used by one *X509\_NAME* object at a time.

**X509\_NAME\_ENTRY\_new**() allocates and initializes an empty *X509\_NAME\_ENTRY* object, representing an ASN.1 *RelativeDistinguishedName* structure defined in RFC 5280 section 4.1.2.4, but containing not more than one type-value-pair.

**X509\_NAME\_ENTRY\_free**() frees *ne* and the type and value contained in it.

**X509\_NAME\_ENTRY\_get\_object**() retrieves the field type of *ne* in an *ASN1\_OBJECT* structure. **X509\_NAME\_ENTRY\_get\_data**() retrieves the field value of *ne* in an *ASN1\_STRING* structure. These two functions can be used to examine an *X509\_NAME\_ENTRY* object as returned by X509\_NAME\_get\_entry(3).

**X509\_NAME\_ENTRY\_set**() retrieves the index of the X.501 *RelativeDistinguishedName* (RDN) that *ne* is part of in the X.501 *Name* object using it. The first RDN has index 0. If an RDN consists of more than one *X509\_NAME\_ENTRY* object, they all share the same index. In practice, RDNs containing more than one type-value-pair are rarely used, so if an *X509\_NAME* *\*name* object uses *ne*, then **X509\_NAME\_ENTRY\_set**(*ne*) usually agrees with **sk\_X509\_NAME\_ENTRY\_find**(*name-\>entries*, *ne*), but when multi-pair RDNs are used, it may be smaller.

**X509\_NAME\_ENTRY\_set\_object**() sets the field type of *ne* to *obj*.

**X509\_NAME\_ENTRY\_set\_data**() sets the field value of *ne* to the given string *type* and the value determined by *bytes* and *len*. If the *type* argument is positive and includes the *MBSTRING\_FLAG* bit, ASN1\_STRING\_set\_by\_NID(3) is used for setting the value, passing the *type* as the *inform* argument and using the *nid* corresponding to *ne*.

**X509\_NAME\_ENTRY\_create\_by\_txt**(), **X509\_NAME\_ENTRY\_create\_by\_NID**(), and **X509\_NAME\_ENTRY\_create\_by\_OBJ**() create and return an *X509\_NAME\_ENTRY* structure.

Except for **X509\_NAME\_ENTRY\_get\_object**() and **X509\_NAME\_ENTRY\_get\_data**(), these functions are rarely used because *X509\_NAME\_ENTRY* structures are almost always part of *X509\_NAME* structures and the functions described in X509\_NAME\_add\_entry\_by\_txt(3) are typically used to create and add new entries in a single operation.

The arguments of these functions support similar options to the similarly named ones described in X509\_NAME\_add\_entry\_by\_txt(3). So for example *type* can be set to MBSTRING\_ASC, but in the case of **X509\_NAME\_ENTRY\_set\_data**() the field type must be set first so the relevant field information can be looked up internally.

## RETURN VALUES

The **X509\_NAME\_ENTRY\_new**() function returns a valid *X509\_NAME\_ENTRY* structure if successful; otherwise NULL is returned and an error code can be retrieved with ERR\_get\_error(3).

**X509\_NAME\_ENTRY\_get\_object**() returns a valid *ASN1\_OBJECT* structure if it is set or NULL if an error occurred.

**X509\_NAME\_ENTRY\_get\_data**() returns a valid *ASN1\_STRING* structure if it is set or NULL if an error occurred.

**X509\_NAME\_ENTRY\_set**() returns the zero-based index of the RDN *ne* is used in, or 0 if *ne* is not yet used by any *X509\_NAME* object.

The **X509\_NAME\_ENTRY\_set\_object**() function returns 1 if successful; otherwise 0 is returned and an error code can be retrieved with ERR\_get\_error(3).

**X509\_NAME\_ENTRY\_set\_data**() returns 1 on success or 0 on error. In some cases of failure, the reason can be determined with ERR\_get\_error(3).

**X509\_NAME\_ENTRY\_create\_by\_txt**(), **X509\_NAME\_ENTRY\_create\_by\_NID**(), and **X509\_NAME\_ENTRY\_create\_by\_OBJ**() return a valid *X509\_NAME\_ENTRY* structure on success or NULL if an error occurred. In some cases of failure, the reason can be determined with ERR\_get\_error(3).

## SEE ALSO

OBJ\_nid2obj(3), X509\_NAME\_add\_entry(3), X509\_NAME\_get\_entry(3), X509\_NAME\_new(3)

## STANDARDS

RFC 5280: Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile

ITU-T Recommendation X.501, also known as ISO/IEC 9594-2: Information Technology  Open Systems Interconnection  The Directory: Models, section 9.3: Relative distinguished name

## HISTORY

**X509\_NAME\_ENTRY\_new**() and **X509\_NAME\_ENTRY\_free**() first appeared in SSLeay 0.5.1. **X509\_NAME\_ENTRY\_get\_object**(), **X509\_NAME\_ENTRY\_get\_data**(), **X509\_NAME\_ENTRY\_set\_object**(), **X509\_NAME\_ENTRY\_set\_data**(), **X509\_NAME\_ENTRY\_create\_by\_NID**(), and **X509\_NAME\_ENTRY\_create\_by\_OBJ**() first appeared in SSLeay 0.8.0. These functions have been available since OpenBSD 2.4.

**X509\_NAME\_ENTRY\_create\_by\_txt**() first appeared in OpenSSL 0.9.5 and has been available since OpenBSD 2.7.

**X509\_NAME\_ENTRY\_set**() first appeared in OpenSSL 1.1.0 and has been available since OpenBSD 6.3.

## CAVEATS

Despite its name, **X509\_NAME\_ENTRY\_set**() does not set anything. Something like “X509\_NAME\_ENTRY\_get\_set” would have been a better name.
