]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic-be: Make the secret derivation works for QUIC backends (USE_QUIC_OPENSSL_...
authorFrederic Lecaille <flecaille@haproxy.com>
Wed, 28 May 2025 14:30:41 +0000 (16:30 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 11 Jun 2025 16:37:34 +0000 (18:37 +0200)
quic_tls_compat_keylog_callback() is the callback used by the QUIC OpenSSL
compatibility module to derive the TLS secrets from other secrets provided
by keylog. The <write> local variable to this function is initialized to denote
the direction (write to send, read to receive) the secret is supposed to be used
for. That said, as the QUIC cryptographic algorithms are symmetrical, the
direction is inversed between the peer: a secret which is used to write/send/cipher
data from a peer point of view is also the secret which is used to
read/receive/decipher data. This was confirmed by the fact that without this
patch, the TLS stack first provides the peer with Handshake to send/cipher
data. The client could not use such secret to decipher the Handshake packets
received from the server. This patch simply reverse the direction stored by
<write> variable to make the secrets derivation works for the QUIC client.

src/quic_openssl_compat.c

index 2f36c68d61846e194d662776dfad76e1d867bc96..f293419e3d6a660572132bd4cf41e2759dc59010 100644 (file)
@@ -150,22 +150,22 @@ void quic_tls_compat_keylog_callback(const SSL *ssl, const char *line)
        if (sizeof(QUIC_OPENSSL_COMPAT_CLIENT_HANDSHAKE) - 1 == n &&
            !strncmp(start, QUIC_OPENSSL_COMPAT_CLIENT_HANDSHAKE, n)) {
                level = ssl_encryption_handshake;
-               write = 0;
+               write = qc_is_listener(qc) ? 0 : 1;
        }
        else if (sizeof(QUIC_OPENSSL_COMPAT_SERVER_HANDSHAKE) - 1 == n &&
                 !strncmp(start, QUIC_OPENSSL_COMPAT_SERVER_HANDSHAKE, n)) {
                level = ssl_encryption_handshake;
-               write = 1;
+               write = qc_is_listener(qc) ? 1 : 0;
        }
        else if (sizeof(QUIC_OPENSSL_COMPAT_CLIENT_APPLICATION) - 1 == n &&
                 !strncmp(start, QUIC_OPENSSL_COMPAT_CLIENT_APPLICATION, n)) {
                level = ssl_encryption_application;
-               write = 0;
+               write = qc_is_listener(qc) ? 0 : 1;
        }
        else if (sizeof(QUIC_OPENSSL_COMPAT_SERVER_APPLICATION) - 1 == n &&
                 !strncmp(start, QUIC_OPENSSL_COMPAT_SERVER_APPLICATION, n)) {
                level = ssl_encryption_application;
-               write = 1;
+               write = qc_is_listener(qc) ? 1 : 0;
        }
        else
                goto leave;