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
The following commit(s) were added to refs/heads/1.3.x by this push:
new b1f1f2577 Update connection context when SNI selects a different SSL
context
b1f1f2577 is described below
commit b1f1f2577fa9c7a029dd61cef9df3117a8335798
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Nov 23 14:26:41 2026 +0000
Update connection context when SNI selects a different SSL context
When SNI switched the SSL_CTX, con->ctx and app_data2 still referenced
the default host's context so client certificate verification used the
default host's settings rather than those of the selected host.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---
native/src/sslcontext.c | 13 +++++++++++++
xdocs/miscellaneous/changelog.xml | 6 ++++++
2 files changed, 19 insertions(+)
diff --git a/native/src/sslcontext.c b/native/src/sslcontext.c
index 690d8972a..19c161619 100644
--- a/native/src/sslcontext.c
+++ b/native/src/sslcontext.c
@@ -118,8 +118,14 @@ int ssl_callback_ServerNameIndication(SSL *ssl, int *al,
tcn_ssl_ctxt_t *c)
(*env)->DeleteLocalRef(env, hostname);
if (new_ssl_context != 0 && new_ssl_context != original_ssl_context) {
+ tcn_ssl_conn_t *con = (tcn_ssl_conn_t *)SSL_get_app_data(ssl);
new_c = J2P(new_ssl_context, tcn_ssl_ctxt_t *);
SSL_set_SSL_CTX(ssl, new_c->ctx);
+ /* Ensure the verify callbacks use the settings of the selected host */
+ SSL_set_app_data2(ssl, new_c);
+ if (con != NULL) {
+ con->ctx = new_c;
+ }
}
return SSL_TLSEXT_ERR_OK;
@@ -206,9 +212,16 @@ give_up:
(*env)->DeleteLocalRef(env, hostname);
if (new_ssl_context != 0 && new_ssl_context != original_ssl_context) {
SSL_CTX *ctx;
+ tcn_ssl_conn_t *con = (tcn_ssl_conn_t *)SSL_get_app_data(ssl);
new_c = J2P(new_ssl_context, tcn_ssl_ctxt_t *);
ctx = SSL_set_SSL_CTX(ssl, new_c->ctx);
+ /* Ensure the verify callbacks use the settings of the selected
host */
+ SSL_set_app_data2(ssl, new_c);
+ if (con != NULL) {
+ con->ctx = new_c;
+ }
+
/* Copied from httpd (modules/ssl/ssl_engine_kernel.c) */
SSL_set_options(ssl, SSL_CTX_get_options(ctx));
SSL_set_min_proto_version(ssl, SSL_CTX_get_min_proto_version(ctx));
diff --git a/xdocs/miscellaneous/changelog.xml
b/xdocs/miscellaneous/changelog.xml
index d644e37b1..19283c795 100644
--- a/xdocs/miscellaneous/changelog.xml
+++ b/xdocs/miscellaneous/changelog.xml
@@ -32,6 +32,12 @@
</p>
</section>
<section name="1.3.11" rtext="development in progress">
+ <changelog>
+ <fix>
+ When using SNI to select a host, update all SSL context references to the
+ new SSL context. (markt)
+ </fix>
+ </changelog>
</section>
<section name="1.3.10" rtext="2026-10-29">
<changelog>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]