Constify X509_to_X509_REQ and X509_REQ_to_X509

Modify both functions to accept and return a const X509, respectively.

Again, neither of these functions appear documented, so omitting the
HISTORY updates here, though we should look into why they are missing
docs.

Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Fri Feb 20 16:27:15 2026
(Merged from https://github.com/openssl/openssl/pull/30072)
This commit is contained in:
Neil Horman 2026-02-18 15:51:20 -05:00
parent 9c1d0e772d
commit 37436ba697
3 changed files with 5 additions and 5 deletions

View file

@ -17,7 +17,7 @@
#include <openssl/objects.h>
#include <openssl/buffer.h>
X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey)
const X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey)
{
X509 *ret = NULL;
X509_CINF *xi = NULL;
@ -58,7 +58,7 @@ X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey)
if (!X509_sign(ret, pkey, EVP_md5()))
goto err;
return ret;
return (const X509 *)ret;
err:
X509_free(ret);

View file

@ -19,7 +19,7 @@
#include <openssl/buffer.h>
#include <openssl/pem.h>
X509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md)
X509_REQ *X509_to_X509_REQ(const X509 *x, EVP_PKEY *pkey, const EVP_MD *md)
{
X509_REQ *ret;
X509_REQ_INFO *ri;

View file

@ -516,8 +516,8 @@ const char *X509_get_default_cert_dir_env(void);
const char *X509_get_default_cert_file_env(void);
const char *X509_get_default_private_dir(void);
X509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey);
X509_REQ *X509_to_X509_REQ(const X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
const X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey);
DECLARE_ASN1_FUNCTIONS(X509_ALGOR)
DECLARE_ASN1_ENCODE_FUNCTIONS(X509_ALGORS, X509_ALGORS, X509_ALGORS)