You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by yl...@apache.org on 2024/07/08 15:06:14 UTC
svn commit: r1919026 - /httpd/httpd/trunk/modules/md/md_crypt.c
Author: ylavic
Date: Mon Jul 8 15:06:14 2024
New Revision: 1919026
URL: http://svn.apache.org/viewvc?rev=1919026&view=rev
Log:
mod_md: Keep compat with openssl < 1.1
EVP_PKEY_get0_RSA() does not exist in openssl < 1.1, use EVP_PKEY_get1_RSA()
instead, hence RSA_free() the returned ref to avoid a leak.
Modified:
httpd/httpd/trunk/modules/md/md_crypt.c
Modified: httpd/httpd/trunk/modules/md/md_crypt.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/md/md_crypt.c?rev=1919026&r1=1919025&r2=1919026&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/md/md_crypt.c (original)
+++ httpd/httpd/trunk/modules/md/md_crypt.c Mon Jul 8 15:06:14 2024
@@ -63,6 +63,10 @@
|| LIBRESSL_VERSION_NUMBER >= 0x3050000fL)
/* Missing from LibreSSL < 3.5.0 and only available since OpenSSL v1.1.x */
#include <openssl/ct.h>
+#define MD_HAVE_CT 1
+#endif
+#ifndef MD_HAVE_CT
+#define MD_HAVE_CT 0
#endif
static int initialized;
@@ -978,42 +982,64 @@ static const char *bn64(const BIGNUM *b,
const char *md_pkey_get_rsa_e64(md_pkey_t *pkey, apr_pool_t *p)
{
+ const char *e64 = NULL;
+
#if OPENSSL_VERSION_NUMBER < 0x30000000L
+
+#if OPENSSL_VERSION_NUMBER < 0x10101000L
+ RSA *rsa = EVP_PKEY_get1_RSA(pkey->pkey);
+#else
const RSA *rsa = EVP_PKEY_get0_RSA(pkey->pkey);
+#endif
if (rsa) {
const BIGNUM *e;
RSA_get0_key(rsa, NULL, &e, NULL);
- return bn64(e, p);
+ e64 = bn64(e, p);
+#if OPENSSL_VERSION_NUMBER < 0x10101000L
+ RSA_free(rsa);
+#endif
}
-#else
+
+#else /* OPENSSL_VERSION_NUMBER >= 0x30000000L */
BIGNUM *e = NULL;
if (EVP_PKEY_get_bn_param(pkey->pkey, OSSL_PKEY_PARAM_RSA_E, &e)) {
- const char *e64 = bn64(e, p);
+ e64 = bn64(e, p);
BN_free(e);
- return e64;
}
#endif
- return NULL;
+
+ return e64;
}
const char *md_pkey_get_rsa_n64(md_pkey_t *pkey, apr_pool_t *p)
{
+ const char *n64 = NULL;
+
#if OPENSSL_VERSION_NUMBER < 0x30000000L
+
+#if OPENSSL_VERSION_NUMBER < 0x10101000L
+ RSA *rsa = EVP_PKEY_get1_RSA(pkey->pkey);
+#else
const RSA *rsa = EVP_PKEY_get0_RSA(pkey->pkey);
+#endif
if (rsa) {
const BIGNUM *n;
RSA_get0_key(rsa, &n, NULL, NULL);
- return bn64(n, p);
+ n64 = bn64(n, p);
+#if OPENSSL_VERSION_NUMBER < 0x10101000L
+ RSA_free(rsa);
+#endif
}
-#else
+
+#else /* OPENSSL_VERSION_NUMBER >= 0x30000000L */
BIGNUM *n = NULL;
if (EVP_PKEY_get_bn_param(pkey->pkey, OSSL_PKEY_PARAM_RSA_N, &n)) {
- const char *n64 = bn64(n, p);
+ n64 = bn64(n, p);
BN_free(n);
- return n64;
}
#endif
- return NULL;
+
+ return n64;
}
apr_status_t md_crypt_sign64(const char **psign64, md_pkey_t *pkey, apr_pool_t *p,
@@ -2037,11 +2063,10 @@ out:
return rv;
}
+#if MD_HAVE_CT
#define MD_OID_CT_SCTS_NUM "1.3.6.1.4.1.11129.2.4.2"
#define MD_OID_CT_SCTS_SNAME "CT-SCTs"
#define MD_OID_CT_SCTS_LNAME "CT Certificate SCTs"
-
-#ifndef OPENSSL_NO_CT
static int get_ct_scts_nid(void)
{
int nid = OBJ_txt2nid(MD_OID_CT_SCTS_NUM);
@@ -2065,7 +2090,7 @@ const char *md_nid_get_lname(int nid)
apr_status_t md_cert_get_ct_scts(apr_array_header_t *scts, apr_pool_t *p, const md_cert_t *cert)
{
-#ifndef OPENSSL_NO_CT
+#if MD_HAVE_CT
int nid, i, idx, critical;
STACK_OF(SCT) *sct_list;
SCT *sct_handle;