D2I_X509_REQ(3)

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

πŸ‘‘ D2I_X509_REQ πŸ‘‘

okay so this is the manual page for the section-3 libcrypto functions you're gonna meet in literally every "certificate signing request" moment of your life, and it's called D2I_X509_REQ(3) πŸ’…. It's all about turning PKCS#10 certification requests into bytes and back again. no cap.


πŸŽ€ NAME πŸŽ€

the whole squad, in alphabetical-ish order:

d2i_X509_REQ, i2d_X509_REQ, d2i_X509_REQ_bio, d2i_X509_REQ_fp, i2d_X509_REQ_bio, i2d_X509_REQ_fp, d2i_X509_REQ_INFO, i2d_X509_REQ_INFO β€” decode and encode PKCS#10 certification requests ✨


✨ SYNOPSIS ✨

first things first, she lives in the libcrypto library, so:

library β€œlibcrypto” #include <openssl/x509.h>

then the actual function lineup, copied exactly because we do not play with prototypes around here 🫢:

X509_REQ *
d2i_X509_REQ(X509_REQ **val_out, const unsigned char **der_in,
    long length);
int
i2d_X509_REQ(X509_REQ *val_in, unsigned char **der_out);
X509_REQ *
d2i_X509_REQ_bio(BIO *in_bio, X509_REQ **val_out);
X509_REQ *
d2i_X509_REQ_fp(FILE *in_fp, X509_REQ **val_out);
int
i2d_X509_REQ_bio(BIO *out_bio, X509_REQ *val_in);
int
i2d_X509_REQ_fp(FILE *out_fp, X509_REQ *val_in);
X509_REQ_INFO *
d2i_X509_REQ_INFO(X509_REQ_INFO **val_out, const unsigned char **der_in,
    long length);
int
i2d_X509_REQ_INFO(X509_REQ_INFO *val_in, unsigned char **der_out);

πŸ’– DESCRIPTION πŸ’–

So these functions decode and encode PKCS#10 certification requests, periodt. πŸ¦‹ And lowkey important: for the details about the semantics, examples, caveats, and bugs, go read ASN1_item_d2i(3) β€” she's the main character of this whole genre, iykyk.

  • d2i_X509_REQ() and i2d_X509_REQ() β€” decode and encode an ASN.1 CertificationRequest structure defined in RFC 2986 section 4.2. iconic behavior honestly πŸ”₯
  • d2i_X509_REQ_bio(), d2i_X509_REQ_fp(), i2d_X509_REQ_bio(), and i2d_X509_REQ_fp() β€” basically the same thing except they decode or encode using a BIO or FILE pointer. same energy, different plumbing πŸ’…
  • d2i_X509_REQ_INFO() and i2d_X509_REQ_INFO() β€” decode and encode an ASN.1 CertificationRequestInfo structure defined in RFC 2986 section 4.1. she's the inner part, the little sister, and she's valid 🌸
ok real talk β€” this page just points you at ASN1_item_d2i(3) for the scary parts. If something goes weird with these, that's where the lore lives, not here, fr fr.

πŸ¦‹ RETURN VALUES πŸ¦‹

the receipts on what you get back:

  • d2i_X509_REQ(), d2i_X509_REQ_bio(), and d2i_X509_REQ_fp() return an X509_REQ object or NULL if an error occurs 😭
  • d2i_X509_REQ_INFO() returns an X509_REQ_INFO object or NULL if an error occurs 😭
  • i2d_X509_REQ() and i2d_X509_REQ_INFO() return the number of bytes successfully encoded or a negative value if an error occurs πŸ’€ (note the negative, bestie, it's not a 0, don't write your error check wrong)
  • i2d_X509_REQ_bio() and i2d_X509_REQ_fp() return 1 for success or 0 if an error occurs πŸ™ˆ (yeah, this one's just a humble little boolean, she's different from the others)

πŸ”₯ SEE ALSO πŸ”₯

  • ASN1_item_d2i(3) β€” the big sister page with the actual semantics, examples, caveats, and bugs
  • PEM_read_X509_REQ(3) β€” if you're a PEM girlie instead of a DER girlie
  • X509_REQ_new(3) β€” for when you need a fresh blank one to start with 🫢

🌈 STANDARDS 🌈

RFC 2986: PKCS #10: Certification Request Syntax Specification β€” and yes that's the whole entry, she keeps it cute and short πŸ’œ


🧚 HISTORY 🧚

past self, present self, future self:

d2i_X509_REQ(), i2d_X509_REQ(), d2i_X509_REQ_fp(), i2d_X509_REQ_fp(), d2i_X509_REQ_INFO(), and i2d_X509_REQ_INFO() first appeared in SSLeay 0.5.1. ✨

d2i_X509_REQ_bio() and i2d_X509_REQ_bio() first appeared in SSLeay 0.6.0. (they're the young ones, they dropped a whole version later, slay for them) ✨

These functions have been available since OpenBSD 2.4. older than most of us and still serving, tbh πŸ‘‘


okay bye and good luck with your certification requests, bestie, go decode something iconic πŸŽ€πŸ’– and remember this page came courtesy of Debian, dated June 8, 2025 β€” that's the source/version and date sign-off, you're welcome ⭐

πŸ“¦ where this page comes from