D2I_X509_NAME(3)
π NAME π
okay so bestie, this is D2I_X509_NAME(3) from libcrypto, and it's the manual page for decoding and encoding X.501 Name objects. The whole squad is d2i_X509_NAME, i2d_X509_NAME, X509_NAME_get0_der, X509_NAME_dup, X509_NAME_set, d2i_X509_NAME_ENTRY, i2d_X509_NAME_ENTRY, and X509_NAME_ENTRY_dup. periodt π
β¨ SYNOPSIS β¨
library βlibcryptoβ #include <openssl/x509.h> β and here's the exact code, no cap:
library βlibcryptoβ #include <openssl/x509.h>
X509_NAME *
d2i_X509_NAME(X509_NAME **val_out, const unsigned char **der_in,
long length);
int
i2d_X509_NAME(X509_NAME *val_in, unsigned char **der_out);
int
X509_NAME_get0_der(X509_NAME *val_in, const unsigned char **der_out,
size_t *out_len);
X509_NAME *
X509_NAME_dup(X509_NAME *val_in);
int
X509_NAME_set(X509_NAME **val_out, X509_NAME *val_in);
X509_NAME_ENTRY *
d2i_X509_NAME_ENTRY(X509_NAME_ENTRY **val_out,
const unsigned char **der_in, long length);
int
i2d_X509_NAME_ENTRY(X509_NAME_ENTRY *val_in, unsigned char **der_out);
X509_NAME_ENTRY *
X509_NAME_ENTRY_dup(X509_NAME_ENTRY *val_in);
πΈ DESCRIPTION πΈ
These functions decode and encode X.501 Name objects using DER format. For the whole semantics, examples, caveats, and bugs situation, go see ASN1_item_d2i(3) β that's the reference bestie, iykyk.
d2i_X509_NAME() and i2d_X509_NAME() decode and encode an ASN.1 Name structure defined in RFC 5280 section 4.1.2.4. slay.
X509_NAME_get0_der() is a variant of i2d_X509_NAME() that does not copy the encoded output β instead it returns a pointer to the internally cached DER-encoded version of the name. Also, it does not return the length of the output in bytes, but instead stores it in out_len. If the cached encoded form happens to be out of date, both functions update it before copying it or returning a pointer to it. iconic behavior honestly.
X509_NAME_dup() copies val_in by calling i2d_X509_NAME() and d2i_X509_NAME().
X509_NAME_set() makes sure that *val_out contains the same data as val_in after the call, except that it fails if val_in is NULL. If *val_out is the same pointer as val_in, the function succeeds without changing anything. Otherwise, it copies val_in using X509_NAME_dup(), and in case of success, it frees *val_out and sets it to a pointer to the new object. When the function fails, it never changes anything. In any case, val_in remains valid and may or may not be the same pointer as *val_out after the call. no surprises, just precise little gremlin rules π
d2i_X509_NAME_ENTRY() and i2d_X509_NAME_ENTRY() decode and encode an ASN.1 RelativeDistinguishedName structure defined in RFC 5280 section 4.1.2.4.
X509_NAME_ENTRY_dup() copies val_in by calling i2d_X509_NAME_ENTRY() and d2i_X509_NAME_ENTRY().
π RETURN VALUES π
d2i_X509_NAME()andX509_NAME_dup()β return the newX509_NAMEobject orNULLif an error occurs.X509_NAME_set()andX509_NAME_get0_der()β return1on success or0if an error occurs.d2i_X509_NAME_ENTRY()andX509_NAME_ENTRY_dup()β return the newX509_NAME_ENTRYobject orNULLif an error occurs.i2d_X509_NAME()andi2d_X509_NAME_ENTRY()β return the number of bytes successfully encoded or a negative value if an error occurs.
π¦ SEE ALSO π¦
go read these next bestie, the lore is real π«Ά
π STANDARDS π
RFC 5280: Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) ProfileITU-T Recommendation X.690, also known as ISO/IEC 8825-1: Information technology - ASN.1 encoding rules: Specification of Basic Encoding Rules (BER), Canonical Encoding Rules (CER) and Distinguished Encoding Rules (DER).
π HISTORY π
X509_NAME_dup()first appeared in SSLeay 0.4.4.d2i_X509_NAME(),i2d_X509_NAME(),d2i_X509_NAME_ENTRY(),i2d_X509_NAME_ENTRY(), andX509_NAME_ENTRY_dup()first appeared in SSLeay 0.5.1.X509_NAME_set()first appeared in SSLeay 0.8.0.- These functions have been available since OpenBSD 2.4.
X509_NAME_get0_der()first appeared in OpenSSL 1.1.0 and has been available since OpenBSD 6.3.
and that's the whole page, bestie β D2I_X509_NAME(3) from Debian, dated June 8, 2025, signing off with a lil kiss πβ¨
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2016, 2018 Ingo Schwarze <schwarze@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms