]> git.kaiwu.me - nginx.git/commitdiff
SSL: workaround for SSL_get_negotiated_group() with no session master
authorAnuj <anu.sharma@f5.com>
Thu, 26 Nov 2026 14:05:31 +0000 (14:05 +0000)
committerSergey Kandaurov <pluknet@nginx.com>
Thu, 26 Nov 2026 16:43:25 +0000 (20:43 +0400)
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

index 27635855cbcbb8a4baf4f82dedb6626c838b4385..bcd026c1be5183e7b8dd6f69428d24956defa4db 100644 (file)
@@ -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) {