diff --git a/src/ssl_sample.c b/src/ssl_sample.c index 7eee065fd..30a616253 100644 --- a/src/ssl_sample.c +++ b/src/ssl_sample.c @@ -1855,6 +1855,9 @@ static int smp_fetch_ssl_x_keylog(const struct arg *args, struct sample *smp, co char *src = NULL; const char *sfx; + if (global_ssl.keylog <= 0) + return 0; + conn = (kw[4] != 'b') ? objt_conn(smp->sess->origin) : smp->strm ? sc_conn(smp->strm->scb) : NULL; diff --git a/src/ssl_sock.c b/src/ssl_sock.c index e066f286d..2a4d64429 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -4979,7 +4979,9 @@ static int ssl_sock_prepare_ctx(struct bind_conf *bind_conf, struct ssl_bind_con SSL_CTX_set_msg_callback(ctx, ssl_sock_msgcbk); #endif #ifdef HAVE_SSL_KEYLOG - SSL_CTX_set_keylog_callback(ctx, SSL_CTX_keylog); + /* only activate the keylog callback if it was required to prevent performance loss */ + if (global_ssl.keylog > 0) + SSL_CTX_set_keylog_callback(ctx, SSL_CTX_keylog); #endif #if defined(OPENSSL_NPN_NEGOTIATED) && !defined(OPENSSL_NO_NEXTPROTONEG)