From: Nitin Swami Date: Wed, 11 Nov 2026 15:59:47 +0000 (+0530) Subject: QUIC: preserved handshake error with OpenSSL QUIC API X-Git-Url: https://git.kaiwu.me/http/ngx_http_fastcgi_module.html?a=commitdiff_plain;h=6d81cb7c629bd4bb17250d2995e92b2ff309d41b;p=nginx.git QUIC: preserved handshake error with OpenSSL QUIC API 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(). --- diff --git a/src/event/quic/ngx_event_quic_ssl.c b/src/event/quic/ngx_event_quic_ssl.c index 259f5525c..d357f759e 100644 --- a/src/event/quic/ngx_event_quic_ssl.c +++ b/src/event/quic/ngx_event_quic_ssl.c @@ -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; }