]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: add QUIC support when no client_hello_cb
authorWilliam Lallemand <wlallemand@haproxy.org>
Wed, 7 Sep 2022 09:21:34 +0000 (11:21 +0200)
committerWilliam Lallemand <wlallemand@haproxy.org>
Wed, 7 Sep 2022 09:33:28 +0000 (11:33 +0200)
Add QUIC support to the ssl_sock_switchctx_cbk() variant used only when
no client_hello_cb is available.

This could be used with libreSSL implementation of QUIC for example.
It also works with quictls when HAVE_SSL_CLIENT_HELLO_CB is removed from
openss-compat.h

src/ssl_sock.c

index 6567bb980a6f3785db95c48f0f6f850d38c0c297..84e03d33b1cab4424e2890039734156b87ff6093 100644 (file)
@@ -2951,9 +2951,37 @@ int ssl_sock_switchctx_cbk(SSL *ssl, int *al, void *priv)
        const char *wildp = NULL;
        struct ebmb_node *node, *n;
        struct bind_conf *s = priv;
+#ifdef USE_QUIC
+       const uint8_t *extension_data;
+       size_t extension_len;
+       struct quic_conn *qc = SSL_get_ex_data(ssl, ssl_qc_app_data_index);
+#endif /* USE_QUIC */
        int i;
        (void)al; /* shut gcc stupid warning */
 
+#ifdef USE_QUIC
+       if (qc) {
+
+               /* Look for the QUIC transport parameters. */
+               SSL_get_peer_quic_transport_params(ssl, &extension_data, &extension_len);
+               if (extension_len == 0) {
+                       /* This is not redundant. It we only return 0 without setting
+                        * <*al>, this has as side effect to generate another TLS alert
+                        * which would be set after calling quic_set_tls_alert().
+                        */
+                       *al = SSL_AD_MISSING_EXTENSION;
+                       quic_set_tls_alert(qc, SSL_AD_MISSING_EXTENSION);
+                       return SSL_TLSEXT_ERR_NOACK;
+               }
+
+               if (!quic_transport_params_store(qc, 0, extension_data,
+                                                extension_data + extension_len) ||
+                   !qc_conn_finalize(qc, 0)) {
+                       return SSL_TLSEXT_ERR_NOACK;
+               }
+       }
+#endif /* USE_QUIC */
+
        servername = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name);
        if (!servername) {
 #if (!defined SSL_NO_GENERATE_CERTIFICATES)