From 0e0c6edd90593a43d05ef921c046cf284035b1ed Mon Sep 17 00:00:00 2001 From: Anuj Date: Thu, 26 Nov 2026 14:05:31 +0000 Subject: [PATCH] SSL: workaround for SSL_get_negotiated_group() with no session OpenSSL prior to 3.5.0 dereferences a NULL session pointer in SSL_get_negotiated_group() when called on a connection where no session is established yet, fixed in this commit: https://github.com/openssl/openssl/commit/4ca80d3941 Supported OpenSSL versions are not affected, but the workaround is applied for older OpenSSL versions we keep compatibility with. The fix is to check for the session explicitly. --- src/event/ngx_event_openssl.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c index 27635855c..bcd026c1b 100644 --- a/src/event/ngx_event_openssl.c +++ b/src/event/ngx_event_openssl.c @@ -5776,6 +5776,15 @@ ngx_ssl_get_curve(ngx_connection_t *c, ngx_pool_t *pool, ngx_str_t *s) int nid; const char *name; +#if (OPENSSL_VERSION_NUMBER < 0x30500000L) + + if (SSL_get0_session(c->ssl->connection) == NULL) { + s->len = 0; + return NGX_OK; + } + +#endif + nid = SSL_get_negotiated_group(c->ssl->connection); if (nid != NID_undef) { -- 2.47.3