Skip to content

Commit

Permalink
feat(trace): remove server SSLKEYLOGFILE Dump
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhuyan committed Jul 17, 2021
1 parent 7484410 commit e7b8f89
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 41 deletions.
8 changes: 2 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,10 @@ endif()

if (DEFINED ENV{QUIC_ENABLE_LOGGING})
set(QUIC_ENABLE_LOGGING $ENV{QUIC_ENABLE_LOGGING})
if (QUIC_ENABLE_LOGGING)
set(QUIC_TLS_SECRETS_SUPPORT "ON")
endif()
else()
set(QUIC_ENABLE_LOGGING "OFF")
endif()

# @todo for testing only
set(QUIC_TLS_SECRETS_SUPPORT "ON")

if (DEFINED ENV{QUICER_USE_LTTNG})
add_compile_options(-DQUICER_USE_LTTNG)
endif()
Expand All @@ -40,6 +34,8 @@ set(QUIC_BUILD_TEST "OFF")
set(QUIC_BUILD_TOOLS "OFF")
set(QUIC_BUILD_PERF "OFF")

set(QUIC_TLS_SECRETS_SUPPORT "ON")

# src files
set(SOURCES
c_src/quicer_nif.c
Expand Down
12 changes: 5 additions & 7 deletions c_src/quicer_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ limitations under the License.
extern inline void
EncodeHexBuffer(uint8_t *Buffer, uint8_t BufferLen, char *HexString);

extern inline const char* QuicStatusToString(QUIC_STATUS Status);

void
dump_sslkeylogfile(_In_z_ const char *FileName,
_In_ CXPLAT_TLS_SECRETS TlsSecrets)
_In_ CXPLAT_TLS_SECRETS TlsSecrets)
{
FILE *File = NULL;
#ifdef _WIN32
Expand Down Expand Up @@ -238,8 +240,7 @@ _IRQL_requires_max_(DISPATCH_LEVEL)

if (NULL != c_ctx->TlsSecrets && NULL != c_ctx->ssl_keylogfile)
{
dump_sslkeylogfile(c_ctx->ssl_keylogfile,
*(c_ctx->TlsSecrets));
dump_sslkeylogfile(c_ctx->ssl_keylogfile, *(c_ctx->TlsSecrets));
}

destroy_c_ctx(c_ctx);
Expand Down Expand Up @@ -512,10 +513,7 @@ async_connect3(ErlNifEnv *env,

else
{
fprintf(stderr,
"failed to read string ssl_keylogfile");

// fail silently
fprintf(stderr, "failed to read string ssl_keylogfile");
}
}

Expand Down
1 change: 0 additions & 1 deletion c_src/quicer_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ init_l_ctx()
l_ctx->env = enif_alloc_env();
l_ctx->acceptor_queue = AcceptorQueueNew();
l_ctx->lock = enif_mutex_create("quicer:l_ctx");
l_ctx->ssl_key_log_file = NULL;
return l_ctx;
}

Expand Down
1 change: 0 additions & 1 deletion c_src/quicer_ctx.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ typedef struct
ErlNifPid listenerPid;
ErlNifEnv *env;
ErlNifMutex *lock;
char *ssl_key_log_file;
void *reserved1;
void *reserved2;
void *reserved3;
Expand Down
22 changes: 0 additions & 22 deletions c_src/quicer_listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ServerListenerCallback(__unused_parm__ HQUIC Listener,
{
QUIC_STATUS Status = QUIC_STATUS_SUCCESS;
QuicerListenerCTX *l_ctx = (QuicerListenerCTX *)Context;
ErlNifEnv *env = l_ctx->env;
QuicerConnCTX *c_ctx = NULL;
switch (Event->Type)
{
Expand Down Expand Up @@ -82,27 +81,6 @@ ServerListenerCallback(__unused_parm__ HQUIC Listener,
return QUIC_STATUS_INTERNAL_ERROR;
}

// @todo: this is just a poc
l_ctx->ssl_key_log_file = "/tmp/SSLKEYLOGFILE";

if (NULL != l_ctx->ssl_key_log_file)
{
CXPLAT_TLS_SECRETS *TlsSecrets = CXPLAT_ALLOC_NONPAGED(
sizeof(CXPLAT_TLS_SECRETS), QUICER_TLS_SECRETS);

CxPlatZeroMemory(TlsSecrets, sizeof(CXPLAT_TLS_SECRETS));
Status = MsQuic->SetParam(c_ctx->Connection,
QUIC_PARAM_LEVEL_CONNECTION,
QUIC_PARAM_CONN_TLS_SECRETS,
sizeof(CXPLAT_TLS_SECRETS),
TlsSecrets);
if (QUIC_FAILED(Status))
{
break;
}
c_ctx->TlsSecrets = TlsSecrets;
}

break;
default:
break;
Expand Down
2 changes: 1 addition & 1 deletion c_src/quicer_nif.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ ERL_NIF_TERM ATOM_SSL_KEYLOGFILE_NAME;
ATOM(ATOM_SNK_META, ~meta); \
ATOM(ATOM_GEN_CAST, $gen_cast); \
ATOM(ATOM_FUNCTION, function); \
ATOM(ATOM_SNABBKAFFE_NEMESIS, snabbkaffe_nemesis); \
ATOM(ATOM_SNABBKAFFE_NEMESIS, snabbkaffe_nemesis); \
ATOM(ATOM_SSL_KEYLOGFILE_NAME, sslkeylogfile);
HQUIC Registration;
const QUIC_API_TABLE *MsQuic;
Expand Down
5 changes: 2 additions & 3 deletions c_src/quicer_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ limitations under the License.
#define QUICER_OPT_BUFF '40rQ' // Qr04 - QUICER OPT
#define QUICER_SETTINGS '50rQ' // Qr05 - QUICER CONNECTION SETTINGS
#define QUICER_TLS_SECRETS \
'60rQ' // Qr06 - QUICER TLS SECRETS for SSLKeyLogFile
#define QUICER_TRACE \
'70rQ' // Qr07 - QUICER TRACE, unimportant
'60rQ' // Qr06 - QUICER TLS SECRETS for SSLKeyLogFile
#define QUICER_TRACE '70rQ' // Qr07 - QUICER TRACE, unimportant
typedef enum ACCEPTOR_RECV_MODE
{
ACCEPTOR_RECV_MODE_PASSIVE,
Expand Down

0 comments on commit e7b8f89

Please sign in to comment.