D2I_GENERAL_NAME(3)
π D2I_GENERAL_NAME β decode & encode names for X.509 extensions (libcrypto, bestie!)
okay so this whole page is about the little name-blobs that live inside X.509 extensions, and the functions that turn them from raw DER bytes into actual structs and back again. It's from the libcrypto library, and the header you need is:
#include <openssl/x509v3.h>
β¨ SYNOPSIS β¨
GENERAL_NAME *
d2i_GENERAL_NAME(GENERAL_NAME **val_out, const unsigned char **der_in,
long length);
int
i2d_GENERAL_NAME(GENERAL_NAME *val_in, unsigned char **der_out);
GENERAL_NAMES *
d2i_GENERAL_NAMES(GENERAL_NAMES **val_out, const unsigned char **der_in,
long length);
int
i2d_GENERAL_NAMES(GENERAL_NAMES *val_in, unsigned char **der_out);
EDIPARTYNAME *
d2i_EDIPARTYNAME(EDIPARTYNAME **val_out, const unsigned char **der_in,
long length);
int
i2d_EDIPARTYNAME(EDIPARTYNAME *val_in, unsigned char **der_out);
OTHERNAME *
d2i_OTHERNAME(OTHERNAME **val_out, const unsigned char **der_in,
long length);
int
i2d_OTHERNAME(OTHERNAME *val_in, unsigned char **der_out);
πΈ DESCRIPTION πΈ
So these functions decode and encode names that you can use in X.509 extensions. That's the whole vibe. π
For all the semantics, examples, caveats, and bugs β the juicy stuff β go read ASN1_item_d2i(3). That's where the lore lives, iykyk.
Here's the cast, one by one, each doing their little encode/decode thing:
d2i_GENERAL_NAME()andi2d_GENERAL_NAME()β decode and encode an ASN.1GeneralNamestructure, defined in RFC 5280 section 4.2.1.6. β¨d2i_GENERAL_NAMES()andi2d_GENERAL_NAMES()β decode and encode an ASN.1GeneralNamesstructure, also RFC 5280 section 4.2.1.6. (yes it's plural, yes it's a different struct, no they're not the same thing bestie π )d2i_EDIPARTYNAME()andi2d_EDIPARTYNAME()β decode and encode an ASN.1EDIPartyNamestructure, RFC 5280 section 4.2.1.6. iconic.d2i_OTHERNAME()andi2d_OTHERNAME()β decode and encode an ASN.1OtherNamestructure, RFC 5280 section 4.2.1.6. the catch-all main character π«Ά
π RETURN VALUES π
The d2i_* girlies β d2i_GENERAL_NAME(), d2i_GENERAL_NAMES(), d2i_EDIPARTYNAME(), and d2i_OTHERNAME() β return a GENERAL_NAME, GENERAL_NAMES, EDIPARTYNAME, or OTHERNAME object respectively (each one matches its own function, obviously π), or NULL if something went wrong.
The i2d_* girlies β i2d_GENERAL_NAME(), i2d_GENERAL_NAMES(), i2d_EDIPARTYNAME(), and i2d_OTHERNAME() β return the number of bytes successfully encoded, or a negative value if an error occurs. That's it, that's the deal. π
π¦ SEE ALSO π¦
π STANDARDS π
RFC 5280: Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile, section 4.2: Certificate Extensions. that's the source material, periodt. β
π HISTORY π
the origin story, chronologically-ish:
d2i_GENERAL_NAME(),i2d_GENERAL_NAME(),d2i_GENERAL_NAMES(), andi2d_GENERAL_NAMES()first appeared in OpenSSL 0.9.2b and have been available since OpenBSD 2.6. πd2i_OTHERNAME()andi2d_OTHERNAME()first appeared in OpenSSL 0.9.5 and have been available since OpenBSD 2.7. β¨d2i_EDIPARTYNAME()andi2d_EDIPARTYNAME()first appeared in OpenSSL 0.9.7 and have been available since OpenBSD 3.2. π¦
okay that's the whole page, go forth and encode responsibly. π
this lil Debian edition is dated June 8, 2025 β mwah, sending u all the π from the Debian crew, take care bestie!! π«Ά
π¦ 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 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