]> git.kaiwu.me - nginx.git/commitdiff
SSL: disabled saving tickets to session cache.
authorMaxim Dounin <mdounin@mdounin.ru>
Wed, 12 Oct 2022 17:14:34 +0000 (20:14 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Wed, 12 Oct 2022 17:14:34 +0000 (20:14 +0300)
OpenSSL tries to save TLSv1.3 sessions into session cache even when using
tickets for stateless session resumption, "because some applications just
want to know about the creation of a session".  To avoid trashing session
cache with useless data, we do not save such sessions now.

src/event/ngx_event_openssl.c

index 085ec553034d4b8dc00746cb795334e87adeb890..a80f30253c28fc3e163ccbba3794420b63a3c45a 100644 (file)
@@ -3818,6 +3818,23 @@ ngx_ssl_new_session(ngx_ssl_conn_t *ssl_conn, ngx_ssl_session_t *sess)
     ngx_ssl_session_cache_t  *cache;
     u_char                    buf[NGX_SSL_MAX_SESSION_SIZE];
 
+#ifdef TLS1_3_VERSION
+
+    /*
+     * OpenSSL tries to save TLSv1.3 sessions into session cache
+     * even when using tickets for stateless session resumption,
+     * "because some applications just want to know about the creation
+     * of a session"; do not cache such sessions
+     */
+
+    if (SSL_version(ssl_conn) == TLS1_3_VERSION
+        && (SSL_get_options(ssl_conn) & SSL_OP_NO_TICKET) == 0)
+    {
+        return 0;
+    }
+
+#endif
+
     len = i2d_SSL_SESSION(sess, NULL);
 
     /* do not cache too big session */