This is an automated email from the ASF dual-hosted git repository. markt-asf pushed a commit to branch 1.3.x in repository https://gitbox.apache.org/repos/asf/tomcat-native.git
commit 47f6fd9037c498945769662ace5a8332272de0f5 Author: Mark Thomas <[email protected]> AuthorDate: Tue Sep 1 15:39:56 2026 +0100 Replace some deprecated code with OpenSSL 3.0+ equivalent --- native/include/ssl_private.h | 2 +- native/src/sslcontext.c | 8 ++++---- native/src/sslutils.c | 12 ++++++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/native/include/ssl_private.h b/native/include/ssl_private.h index 5cf5a7395..eb2af7821 100644 --- a/native/include/ssl_private.h +++ b/native/include/ssl_private.h @@ -344,7 +344,7 @@ int SSL_password_callback(char *, int, int, void *); void SSL_BIO_close(BIO *); void SSL_BIO_doref(BIO *); DH *SSL_get_dh_params(unsigned keylen); -DH *SSL_dh_GetParamFromFile(const char *); +EVP_PKEY *SSL_dh_GetParamFromFile(const char *); #ifdef HAVE_ECC EC_GROUP *SSL_ec_GetParamFromFile(const char *); #endif diff --git a/native/src/sslcontext.c b/native/src/sslcontext.c index 873e87d88..ed5927cc2 100644 --- a/native/src/sslcontext.c +++ b/native/src/sslcontext.c @@ -1063,7 +1063,7 @@ TCN_IMPLEMENT_CALL(jboolean, SSLContext, setCertificate)(TCN_STDARGS, jlong ctx, int nid; EC_KEY *eckey = NULL; #endif - DH *dhparams; + EVP_PKEY *evp; UNREFERENCED(o); TCN_ASSERT(ctx != 0); @@ -1138,9 +1138,9 @@ TCN_IMPLEMENT_CALL(jboolean, SSLContext, setCertificate)(TCN_STDARGS, jlong ctx, */ /* XXX Does this also work for pkcs12 or only for PEM files? * If only for PEM files move above to the PEM handling */ - if ((idx == 0) && (dhparams = SSL_dh_GetParamFromFile(cert_file))) { - SSL_CTX_set_tmp_dh(c->ctx, dhparams); - DH_free(dhparams); + if ((idx == 0) && (evp = SSL_dh_GetParamFromFile(cert_file))) { + SSL_CTX_set0_tmp_dh_pkey(c->ctx, evp); + EVP_PKEY_free(evp); } #ifdef HAVE_ECC diff --git a/native/src/sslutils.c b/native/src/sslutils.c index fe9edd1ff..c069302ef 100644 --- a/native/src/sslutils.c +++ b/native/src/sslutils.c @@ -202,16 +202,20 @@ int SSL_password_callback(char *buf, int bufsiz, int verify, ** Custom (EC)DH parameter support ** _________________________________________________________________ */ -DH *SSL_dh_GetParamFromFile(const char *file) +EVP_PKEY *SSL_dh_GetParamFromFile(const char *file) { - DH *dh = NULL; + EVP_PKEY *evp = NULL; BIO *bio; if ((bio = BIO_new_file(file, "r")) == NULL) return NULL; - dh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL); + evp = PEM_read_bio_Parameters_ex(bio, NULL, NULL, NULL); BIO_free(bio); - return dh; + if (!EVP_PKEY_is_a(evp, "DH")) { + EVP_PKEY_free(evp); + return NULL; + } + return evp; } #ifdef HAVE_ECC --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
