D2I_X509_REQ(3) | Library Functions Manual | D2I_X509_REQ(3)

# NAME

`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

library “libcrypto”
`#include <openssl/x509.h>`

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

These functions decode and encode PKCS#10 certification requests. For details about the semantics, examples, caveats, and bugs, see ASN1_item_d2i(3).

`d2i_X509_REQ`() and `i2d_X509_REQ`() decode and encode an ASN.1 CertificationRequest structure defined in RFC 2986 section 4.2. `d2i_X509_REQ_bio`(), `d2i_X509_REQ_fp`(), `i2d_X509_REQ_bio`(), and `i2d_X509_REQ_fp`() are similar except that they decode or encode using a BIO or FILE pointer.

`d2i_X509_REQ_INFO`() and `i2d_X509_REQ_INFO`() decode and encode an ASN.1 CertificationRequestInfo structure defined in RFC 2986 section 4.1.

# RETURN VALUES

`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.

`i2d_X509_REQ_bio`() and `i2d_X509_REQ_fp`() return 1 for success or 0 if an error occurs.

# SEE ALSO

ASN1_item_d2i(3), PEM_read_X509_REQ(3), X509_REQ_new(3)

# STANDARDS

RFC 2986: PKCS #10: Certification Request Syntax Specification

# HISTORY

`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. These functions have been available since OpenBSD 2.4.

June 8, 2025 | Debian