LIBRESSL-X509_NAME_ENTRY_GET_OBJECT(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

πŸ’… LIBRESSL-X509_NAME_ENTRY_GET_OBJECT(3) β€” the X.501 relative distinguished name glow-up πŸŽ€

okay so bestie, this is the LIBRESSL-X509_NAME_ENTRY_GET_OBJECT(3) page and honestly? it's giving "small struct, big feelings" ✨. it's a libcrypto thing, so you already know we're in OpenSSL-adjacent territory. buckle up πŸ¦‹


✨ 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 🌸

library libcrypto

#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 πŸ¦‹

so an X.501 RelativeDistinguishedName is basically an ordered set of field-type-and-value pairs, no cap. it's literally the building block for making X.501 Name objects πŸ‘‘. and the X509_NAME_ENTRY object? it stores exactly one of those pairs β€” one field type, one value. that's it, that's the whole vibe πŸ’…

these X509_NAME_ENTRY objects are meant to be used by the X509_NAME objects documented over in X509_NAME_new(3). and here's the tea 🍡: some of the info about how several X509_NAME_ENTRY objects combine to form an X.501 Name lives inside each individual X509_NAME_ENTRY object, not in the X509_NAME object. so a given X509_NAME_ENTRY object can only be used by one X509_NAME object at a time. sharing is not caring here, bestie 😭

  • 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. so like, one pair max, we don't do harem energy here πŸ™ˆ
  • X509_NAME_ENTRY_free() β€” frees ne and the type and value contained in it. clean up your mess, icon behavior ✨
  • 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. both of these are the ones you'd use 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. lowkey a subtle one, so clock it πŸ‘€
  • X509_NAME_ENTRY_set_object() β€” sets the field type of ne to obj. done and dusted πŸ’…
  • X509_NAME_ENTRY_set_data() β€” sets the field value of ne to the given string type and the value determined by bytes and len. and here's the important bit: 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. fr fr, don't skip that flag check πŸ”₯

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. three flavors, same energy πŸ“

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. efficiency slay πŸ’…βœ¨

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. order matters, bestie β€” sequence is everything 🧚


πŸ’– RETURN VALUES πŸ’–

  • X509_NAME_ENTRY_new() β€” 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. 🫢
  • X509_NAME_ENTRY_set_object() β€” 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(), 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) β€” go read these too, iykyk πŸ“šπŸ’œ


⭐ 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

standards-coded, we love to see it πŸ‘‘


πŸŽ€ HISTORY πŸŽ€

X509_NAME_ENTRY_new() and X509_NAME_ENTRY_free() first appeared in SSLeay 0.5.1. and then 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. ancient. iconic. still here πŸ’€βœ¨

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. the baby of the family 🍼


πŸ’€ CAVEATS πŸ’€

not gonna lie, despite its name, X509_NAME_ENTRY_set() does not set anything. it gets. it retrieves. it's a getter with a villain origin story 😭. something like β€œX509_NAME_ENTRY_get_set” would have been a better name. we said what we said πŸ™ˆ


and that's the whole page, bestie! this version came to you from Debian, dated December 21, 2025, and it's the X509_NAME_ENTRY_GET_OBJECT(3) page β€” mwah, go slay some X.509 πŸ’‹πŸ«ΆπŸ’…
πŸ“¦ where this page comes from