diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 08:52:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 08:52:50 +0000 |
commit | 9752fb8037bf6856aad9c51a1a7370ffc866f201 (patch) | |
tree | 054ae5378aa8919e67fa610a348b5f4e8ef9de3b /src/tls.cc | |
parent | Adding upstream version 1.60.0. (diff) | |
download | nghttp2-9752fb8037bf6856aad9c51a1a7370ffc866f201.tar.xz nghttp2-9752fb8037bf6856aad9c51a1a7370ffc866f201.zip |
Adding upstream version 1.61.0.upstream/1.61.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tls.cc')
-rw-r--r-- | src/tls.cc | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -25,9 +25,11 @@ #include "tls.h" #include <cassert> +#include <cstring> #include <vector> #include <mutex> #include <iostream> +#include <fstream> #include <openssl/crypto.h> #include <openssl/conf.h> @@ -176,6 +178,32 @@ int cert_decompress(SSL *ssl, CRYPTO_BUFFER **out, size_t uncompressed_len, } #endif // NGHTTP2_OPENSSL_IS_BORINGSSL && HAVE_LIBBROTLI +namespace { +std::ofstream keylog_file; + +void keylog_callback(const SSL *ssl, const char *line) { + keylog_file.write(line, strlen(line)); + keylog_file.put('\n'); + keylog_file.flush(); +} +} // namespace + +int setup_keylog_callback(SSL_CTX *ssl_ctx) { + auto keylog_filename = getenv("SSLKEYLOGFILE"); + if (!keylog_filename) { + return 0; + } + + keylog_file.open(keylog_filename, std::ios_base::app); + if (!keylog_file) { + return -1; + } + + SSL_CTX_set_keylog_callback(ssl_ctx, keylog_callback); + + return 0; +} + } // namespace tls } // namespace nghttp2 |