D2I_X509_EXTENSION(3) | Library Functions Manual | D2I_X509_EXTENSION(3)

# NAME

`d2i_X509_EXTENSION`, `i2d_X509_EXTENSION`, `d2i_X509_EXTENSIONS`, `i2d_X509_EXTENSIONS` — decode and encode X.509 Extensions

# SYNOPSIS

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

X509_EXTENSION *
`d2i_X509_EXTENSION`(X509_EXTENSION **val_out, const unsigned char **der_in, long length);

int
`i2d_X509_EXTENSION`(X509_EXTENSION *val_in, unsigned char **der_out);

X509_EXTENSIONS *
`d2i_X509_EXTENSIONS`(X509_EXTENSIONS **val_out, const unsigned char **der_in, long length);

int
`i2d_X509_EXTENSIONS`(X509_EXTENSIONS *val_in, unsigned char **der_out);

# DESCRIPTION

`d2i_X509_EXTENSION`() and `i2d_X509_EXTENSION`() decode and encode an ASN.1 Extension structure defined in RFC 5280 section 4.1.

`d2i_X509_EXTENSIONS`() and `i2d_X509_EXTENSIONS`() decode and encode an ASN.1 Extensions structure defined in RFC 5280 section 4.1, which is a SEQUENCE OF Extension.

# RETURN VALUES

`d2i_X509_EXTENSION`() and `d2i_X509_EXTENSIONS`() return an X509_EXTENSION or X509_EXTENSIONS object, respectively, or `NULL` if an error occurs.

`i2d_X509_EXTENSION`() and `i2d_X509_EXTENSIONS`() return the number of bytes successfully encoded or a negative value if an error occurs.

# SEE ALSO

ASN1_item_d2i(3), X509_EXTENSION_new(3), X509V3_get_d2i(3), X509v3_get_ext_by_NID(3)

# STANDARDS

RFC 5280: Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile

# HISTORY

`d2i_X509_EXTENSION`() and `i2d_X509_EXTENSION`() first appeared in SSLeay 0.6.2 and have been available since OpenBSD 2.4.

`d2i_X509_EXTENSIONS`() and `i2d_X509_EXTENSIONS`() first appeared in OpenSSL 0.9.8h and have been available since OpenBSD 4.5.

June 8, 2025 | Debian