From 7d42ef5b22c2b83791cc8a997545a16903870ad3 Mon Sep 17 00:00:00 2001 From: William Lallemand Date: Mon, 6 Jul 2020 11:41:30 +0200 Subject: [PATCH] WIP/MINOR: ssl: add sample fetches for keylog in frontend OpenSSL 1.1.1 provides a callback registering function SSL_CTX_set_keylog_callback, which allows one to receive a string containing the keys to deciphers TLSv1.3. Unfortunately it is not possible to store this data in binary form and we can only get this information using the callback. Which means that we need to store it until the connection is closed. This patches add 2 pools, the first one, pool_head_ssl_keylog is used to store a struct ssl_keylog which will be inserted as a ex_data in a SSL *. The second one is pool_head_ssl_keylog_str which will be used to store the hexadecimal strings. To enable the capture of the keys, you need to set "tune.ssl.keylog on" in your configuration. The following fetches were implemented: ssl_fc_client_early_traffic_secret, ssl_fc_client_handshake_traffic_secret, ssl_fc_server_handshake_traffic_secret, ssl_fc_client_traffic_secret_0, ssl_fc_server_traffic_secret_0, ssl_fc_exporter_secret, ssl_fc_early_exporter_secret --- doc/configuration.txt | 102 +++++++++++++++++++++++ include/haproxy/ssl_sock-t.h | 21 +++++ include/haproxy/ssl_sock.h | 3 + src/cfgparse-ssl.c | 41 +++++++++ src/ssl_sample.c | 68 +++++++++++++++ src/ssl_sock.c | 157 +++++++++++++++++++++++++++++++++++ 6 files changed, 392 insertions(+) diff --git a/doc/configuration.txt b/doc/configuration.txt index 6d472134eb..38fbbd48d5 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -704,6 +704,7 @@ The following keywords are supported in the "global" section : - tune.sndbuf.client - tune.sndbuf.server - tune.ssl.cachesize + - tune.ssl.keylog - tune.ssl.lifetime - tune.ssl.force-private-cache - tune.ssl.maxrecord @@ -2157,6 +2158,44 @@ tune.ssl.force-private-cache this case, adding a first layer of hash-based load balancing before the SSL layer might limit the impact of the lack of session sharing. +tune.ssl.keylog { on | off } + This option activates the logging of the TLS keys. It should be used with + care as it will consume more memory per SSL session and could decrease + performances. This is disabled by default. + + These sample fetches should be used to generate the SSLKEYLOGFILE that is + required to decipher traffic with wireshark. + + https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Key_Log_Format + + The SSLKEYLOG is a series of lines which are formatted this way: + +