Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/thread.h"


static FILE *g_keylog_file = nullptr;
static void KeyLogCallback(const SSL *ssl, const char *line) {
fprintf(g_keylog_file, "%s\n", line);
fflush(g_keylog_file);
}

//////////////////////////////////////////////////////////////////////
// SocketBIO
//////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1031,6 +1038,14 @@ SSL_CTX* OpenSSLAdapter::CreateContext(SSLMode mode, bool enable_cache) {
SSL_CTX_sess_set_new_cb(ctx, &OpenSSLAdapter::NewSSLSessionCallback);
}

const char *keylog_filepath = getenv("SSLKEYLOGFILE");
if (keylog_filepath) {
g_keylog_file = fopen(keylog_filepath, "a");
if (g_keylog_file) {
SSL_CTX_set_keylog_callback(ctx, KeyLogCallback);
}
}

return ctx;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@
namespace rtc {
namespace {
using ::webrtc::SafeTask;

static FILE *g_keylog_file = nullptr;
static void KeyLogCallback(const SSL *ssl, const char *line) {
fprintf(g_keylog_file, "%s\n", line);
fflush(g_keylog_file);
}

// SRTP cipher suite table. `internal_name` is used to construct a
// colon-separated profile strings which is needed by
// SSL_CTX_set_tlsext_use_srtp().
Expand Down Expand Up @@ -1036,6 +1043,14 @@ SSL_CTX* OpenSSLStreamAdapter::SetupSSLContext() {
return nullptr;
}

const char *keylog_filepath = getenv("SSLKEYLOGFILE");
if (keylog_filepath) {
g_keylog_file = fopen(keylog_filepath, "a");
if (g_keylog_file) {
SSL_CTX_set_keylog_callback(ctx, KeyLogCallback);
}
}

if (support_legacy_tls_protocols_flag_) {
// TODO(https://bugs.webrtc.org/10261): Completely remove this branch in
// M84.
Expand Down