]> git.kaiwu.me - nginx.git/commitdiff
QUIC: preserved handshake error with OpenSSL QUIC API
authorNitin Swami <n.swami@f5.com>
Wed, 11 Nov 2026 15:59:47 +0000 (21:29 +0530)
committerSergey Kandaurov <pluknet@nginx.com>
Wed, 25 Nov 2026 18:50:43 +0000 (22:50 +0400)
Previously, ngx_quic_cbs_send() unconditionally set the error for
missing ALPN or transport parameters.  If the transport parameters
were rejected earlier, as an example, due to an invalid value, the
TRANSPORT_PARAMETER_ERROR set in ngx_quic_cbs_got_transport_params()
was overwritten with the "missing transport parameters" crypto error,
and the client received a misleading error code.

The fix is to set the error only if no error was set before, similar
to ngx_quic_add_handshake_data().

src/event/quic/ngx_event_quic_ssl.c

index 259f5525c39f4085a44d8415b87b84813fa7eb12..d357f759edb3bc941f4a10c4458659fbfb583aea 100644 (file)
@@ -88,21 +88,28 @@ ngx_quic_cbs_send(ngx_ssl_conn_t *ssl_conn,
     SSL_get0_alpn_selected(ssl_conn, &alpn_data, &alpn_len);
 
     if (alpn_len == 0) {
-        qc->error = NGX_QUIC_ERR_CRYPTO(SSL_AD_NO_APPLICATION_PROTOCOL);
-        qc->error_reason = "missing ALPN extension";
+        if (qc->error == 0) {
+            qc->error = NGX_QUIC_ERR_CRYPTO(SSL_AD_NO_APPLICATION_PROTOCOL);
+            qc->error_reason = "missing ALPN extension";
+
+            ngx_log_error(NGX_LOG_INFO, c->log, 0,
+                          "quic missing ALPN extension");
+        }
 
-        ngx_log_error(NGX_LOG_INFO, c->log, 0,
-                      "quic missing ALPN extension");
         return 1;
     }
 
     if (!qc->client_tp_done) {
         /* RFC 9001, 8.2.  QUIC Transport Parameters Extension */
-        qc->error = NGX_QUIC_ERR_CRYPTO(SSL_AD_MISSING_EXTENSION);
-        qc->error_reason = "missing transport parameters";
 
-        ngx_log_error(NGX_LOG_INFO, c->log, 0,
-                      "missing transport parameters");
+        if (qc->error == 0) {
+            qc->error = NGX_QUIC_ERR_CRYPTO(SSL_AD_MISSING_EXTENSION);
+            qc->error_reason = "missing transport parameters";
+
+            ngx_log_error(NGX_LOG_INFO, c->log, 0,
+                          "missing transport parameters");
+        }
+
         return 1;
     }