X509_REQ_NEW(3) | Library Functions Manual | X509_REQ_NEW(3)

# NAME

`X509_REQ_new`, `X509_REQ_dup`, `X509_to_X509_REQ`, `X509_REQ_free`, `X509_REQ_INFO_new`, `X509_REQ_INFO_free` — PKCS#10 certification requests

# SYNOPSIS

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

X509_REQ *
`X509_REQ_new`(void);

X509_REQ *
`X509_REQ_dup`(X509_REQ *req);

X509_REQ *
`X509_to_X509_REQ`(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);

void
`X509_REQ_free`(X509_REQ *req);

X509_REQ_INFO *
`X509_REQ_INFO_new`(void);

void
`X509_REQ_INFO_free`(X509_REQ_INFO *req_info);

# DESCRIPTION

`X509_REQ_new`() allocates and initializes an empty X509_REQ object, representing an ASN.1 CertificationRequest structure defined in RFC 2986 section 4.2. It can hold a pointer to an X509_REQ_INFO object discussed below together with a cryptographic signature and information about the signature algorithm used.

`X509_REQ_dup`() creates a deep copy of req using ASN1_item_dup(3), setting the reference count of the copy to 1.

`X509_to_X509_REQ`() allocates a new certification request object, copies the subject name and the public key into it from the certificate x, and sets the version to zero. Unless pkey is `NULL`, it also signs the request with X509_REQ_sign(3) using pkey and md.

`X509_REQ_free`() frees req. If req is a `NULL` pointer, no action occurs.

`X509_REQ_INFO_new`() allocates and initializes an empty X509_REQ_INFO object, representing an ASN.1 CertificationRequestInfo structure defined in RFC 2986 section 4.1. It is used inside the X509_REQ object and can hold the subject and the public key of the requested certificate and additional attributes. `X509_REQ_INFO_free`() frees req_info. If req_info is a `NULL` pointer, no action occurs.

# RETURN VALUES

`X509_REQ_new`(), `X509_REQ_dup`(), `X509_to_X509_REQ`(), and `X509_REQ_INFO_new`() return the new X509_REQ or X509_REQ_INFO object, respectively, or `NULL` if an error occurs.

# SEE ALSO

d2i_X509_REQ(3), PEM_read_X509_REQ(3), X509_new(3), X509_REQ_add1_attr(3), X509_REQ_add_extensions(3), X509_REQ_check_private_key(3), X509_REQ_digest(3), X509_REQ_get0_signature(3), X509_REQ_get_pubkey(3), X509_REQ_get_subject_name(3), X509_REQ_get_version(3), X509_REQ_print_ex(3), X509_REQ_sign(3)

# STANDARDS

RFC 2986: PKCS #10: Certification Request Syntax Specification

# HISTORY

`X509_REQ_new`(), `X509_REQ_free`(), `X509_REQ_INFO_new`(), and `X509_REQ_INFO_free`() first appeared in SSLeay 0.4.4, `X509_REQ_dup`() in SSLeay 0.5.1, and `X509_to_X509_REQ`() in SSLeay 0.6.0. These functions have been available since OpenBSD 2.4.

June 8, 2025 | Debian