]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: ssl: create the mux immediately on early data
authorOlivier Houchard <ohouchard@haproxy.com>
Tue, 9 Sep 2025 13:34:32 +0000 (15:34 +0200)
committerOlivier Houchard <cognet@ci0.org>
Tue, 9 Sep 2025 17:01:24 +0000 (19:01 +0200)
If we received early data, and an ALPN has been negociated, then
immediately try to create a mux if we did not have one already.
Generally, at this point we would not have one, as the mux is decided by
the ALPN, however at this point, even if the handshake is not done yet,
we have enough to determine the ALPN, so we can immediately create the
mux.
Doing so makes up able to treat the request immediately, without waiting
for the handshake to be done.

This should be backported up to 2.8.

src/ssl_sock.c

index e0b5b9eee577fea8c3257b9eaeba2cd7f26d3b87..8d6e5b000cd15d2b6fcd91b91153bcbf40537573 100644 (file)
@@ -5608,9 +5608,22 @@ static int ssl_sock_handshake(struct connection *conn, unsigned int flag)
                                goto check_error;
                        }
                        if (read_data > 0) {
+                               const char *alpn;
+                               int len;
+
                                TRACE_DEVEL("Early data read", SSL_EV_CONN_HNDSHK, conn, ctx->ssl);
                                conn->flags |= CO_FL_EARLY_DATA;
                                b_add(&ctx->early_buf, read_data);
+                               if (ssl_sock_get_alpn(conn, ctx, &alpn, &len) != 0) {
+                                       /*
+                                        * We have an ALPN set already, so we
+                                        * know which mux to use, and we have
+                                        * early data, let's create the mux
+                                        * now.
+                                        */
+                                       if (!conn->mux)
+                                               conn_create_mux(conn, NULL);
+                               }
                        }
                        if (ret == SSL_READ_EARLY_DATA_FINISH) {
                                conn->flags &= ~CO_FL_EARLY_SSL_HS;