This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat-native.git
commit a2085fd3dfb1d08a7e4a259200bb413039886435 Author: Mark Thomas <[email protected]> AuthorDate: Thu Dec 11 15:31:36 2025 +0000 Add soft-fail support for OCSP --- native/include/ssl_private.h | 4 +++- native/src/sslconf.c | 20 ++++++++++++++++++++ native/src/sslutils.c | 15 ++++++++------- xdocs/miscellaneous/changelog.xml | 5 +++++ 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/native/include/ssl_private.h b/native/include/ssl_private.h index 3b364e454..e29124524 100644 --- a/native/include/ssl_private.h +++ b/native/include/ssl_private.h @@ -310,6 +310,7 @@ struct tcn_ssl_ctxt_t { int alpn_selector_failure_behavior; /* End add from netty-tcnative */ int no_ocsp_check; + int ocsp_soft_fail; }; #ifdef HAVE_SSL_CONF_CMD @@ -318,7 +319,8 @@ typedef struct tcn_ssl_conf_ctxt_t tcn_ssl_conf_ctxt_t; struct tcn_ssl_conf_ctxt_t { apr_pool_t *pool; SSL_CONF_CTX *cctx; - int no_ocsp_check; + int no_ocsp_check; + int ocsp_soft_fail; }; #endif diff --git a/native/src/sslconf.c b/native/src/sslconf.c index 8285f7d30..3b0f32f39 100644 --- a/native/src/sslconf.c +++ b/native/src/sslconf.c @@ -163,6 +163,16 @@ TCN_IMPLEMENT_CALL(jint, SSLConf, check)(TCN_STDARGS, jlong cctx, return 1; } + if (!strcmp(J2S(cmd), "OCSP_SOFT_FAIL")) { + if (!strcasecmp(J2S(value), "false")) + c->ocsp_soft_fail = 0; + else + c->ocsp_soft_fail = 1; + TCN_FREE_CSTRING(cmd); + TCN_FREE_CSTRING(value); + return 1; + } + SSL_ERR_clear(); value_type = SSL_CONF_cmd_value_type(c->cctx, J2S(cmd)); ec = SSL_ERR_get(); @@ -217,6 +227,7 @@ TCN_IMPLEMENT_CALL(void, SSLConf, assign)(TCN_STDARGS, jlong cctx, // sc->ctx == 0 is allowed! SSL_CONF_CTX_set_ssl_ctx(c->cctx, sc->ctx); sc->no_ocsp_check = c->no_ocsp_check; + sc->ocsp_soft_fail = c->ocsp_soft_fail; } /* Apply a command to an SSL_CONF context */ @@ -265,6 +276,15 @@ TCN_IMPLEMENT_CALL(jint, SSLConf, apply)(TCN_STDARGS, jlong cctx, TCN_FREE_CSTRING(value); return 1; } + if (!strcmp(J2S(cmd), "OCSP_SOFT_FAIL")) { + if (!strcasecmp(J2S(value), "false")) + c->ocsp_soft_fail = 0; + else + c->ocsp_soft_fail = 1; + TCN_FREE_CSTRING(cmd); + TCN_FREE_CSTRING(value); + return 1; + } SSL_ERR_clear(); rc = SSL_CONF_cmd(c->cctx, J2S(cmd), buf != NULL ? buf : J2S(value)); ec = SSL_ERR_get(); diff --git a/native/src/sslutils.c b/native/src/sslutils.c index a10c79739..b70a4aece 100644 --- a/native/src/sslutils.c +++ b/native/src/sslutils.c @@ -299,11 +299,12 @@ int SSL_callback_SSL_verify(int ok, X509_STORE_CTX *ctx) SSL_get_ex_data_X509_STORE_CTX_idx()); tcn_ssl_conn_t *con = (tcn_ssl_conn_t *)SSL_get_app_data(ssl); /* Get verify ingredients */ - int errnum = X509_STORE_CTX_get_error(ctx); - int errdepth = X509_STORE_CTX_get_error_depth(ctx); - int verify = con->ctx->verify_mode; - int depth = con->ctx->verify_depth; - int ocsp_check_type = con->ctx->no_ocsp_check; + int errnum = X509_STORE_CTX_get_error(ctx); + int errdepth = X509_STORE_CTX_get_error_depth(ctx); + int verify = con->ctx->verify_mode; + int depth = con->ctx->verify_depth; + int ocsp_check_type = con->ctx->no_ocsp_check; + int ocsp_soft_fail = con->ctx->ocsp_soft_fail; #if defined(SSL_OP_NO_TLSv1_3) con->pha_state = PHA_COMPLETE; @@ -356,8 +357,8 @@ int SSL_callback_SSL_verify(int ok, X509_STORE_CTX *ctx) } else if (ocsp_response == OCSP_STATUS_UNKNOWN) { errnum = X509_STORE_CTX_get_error(ctx); - if (errnum) - ok = 0 ; + if (errnum != 0 && !(ocsp_soft_fail && errnum == X509_V_ERR_UNABLE_TO_GET_CRL)) + ok = 0; } } } diff --git a/xdocs/miscellaneous/changelog.xml b/xdocs/miscellaneous/changelog.xml index 373719038..05eab5a3b 100644 --- a/xdocs/miscellaneous/changelog.xml +++ b/xdocs/miscellaneous/changelog.xml @@ -44,6 +44,11 @@ <add> Expand verification of OCSP responses. (markt) </add> + <add> + Add the ability to configure the OCSP checks to soft-fail - i.e. if the + responder cannot be contacted or fails to respond in a timely manner the + OCSP check will not fail. (markt) + </add> </changelog> </section> <section name="Changes in 2.0.9"> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
