D2I_X509_REQ(3)
π 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()andi2d_X509_REQ()β decode and encode an ASN.1CertificationRequeststructure defined in RFC 2986 section 4.2. iconic behavior honestly π₯d2i_X509_REQ_bio(),d2i_X509_REQ_fp(),i2d_X509_REQ_bio(), andi2d_X509_REQ_fp()β basically the same thing except they decode or encode using aBIOorFILEpointer. same energy, different plumbing πd2i_X509_REQ_INFO()andi2d_X509_REQ_INFO()β decode and encode an ASN.1CertificationRequestInfostructure 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(), andd2i_X509_REQ_fp()return anX509_REQobject orNULLif an error occurs πd2i_X509_REQ_INFO()returns anX509_REQ_INFOobject orNULLif an error occurs πi2d_X509_REQ()andi2d_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 a0, don't write your error check wrong)i2d_X509_REQ_bio()andi2d_X509_REQ_fp()return1for success or0if 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 bugsPEM_read_X509_REQ(3)β if you're a PEM girlie instead of a DER girlieX509_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
- 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