diff --git a/doc/configuration.txt b/doc/configuration.txt index d2cdf2749..03df57cb9 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -15430,6 +15430,11 @@ ssl_bc_cipher : string Returns the name of the used cipher when the outgoing connection was made over an SSL/TLS transport layer. +ssl_bc_client_random : binary + Returns the client random of the back connection when the incoming connection + was made over an SSL/TLS transport layer. It is useful to to decrypt traffic + sent using ephemeral ciphers. This requires OpenSSL >= 1.1.0, or BoringSSL. + ssl_bc_is_resumed : boolean Returns true when the back connection was made over an SSL/TLS transport layer and the newly created SSL session was resumed using a cached @@ -15454,6 +15459,11 @@ ssl_bc_unique_id : binary returns the TLS unique ID as defined in RFC5929 section 3. The unique id can be encoded to base64 using the converter: "ssl_bc_unique_id,base64". +ssl_bc_server_random : binary + Returns the server random of the back connection when the incoming connection + was made over an SSL/TLS transport layer. It is useful to to decrypt traffic + sent using ephemeral ciphers. This requires OpenSSL >= 1.1.0, or BoringSSL. + ssl_bc_session_id : binary Returns the SSL ID of the back connection when the outgoing connection was made over an SSL/TLS transport layer. It is useful to log if we want to know @@ -15675,6 +15685,11 @@ ssl_fc_cipherlist_xxh : integer "tune.ssl.capture-cipherlist-size" is set greater than 0, however the hash take in account all the data of the cipher list. +ssl_fc_client_random : binary + Returns the client random of the front connection when the incoming connection + was made over an SSL/TLS transport layer. It is useful to to decrypt traffic + sent using ephemeral ciphers. This requires OpenSSL >= 1.1.0, or BoringSSL. + ssl_fc_has_crt : boolean Returns true if a client certificate is present in an incoming connection over SSL/TLS transport layer. Useful if 'verify' statement is set to 'optional'. @@ -15719,6 +15734,11 @@ ssl_fc_unique_id : binary returns the TLS unique ID as defined in RFC5929 section 3. The unique id can be encoded to base64 using the converter: "ssl_bc_unique_id,base64". +ssl_fc_server_random : binary + Returns the server random of the front connection when the incoming connection + was made over an SSL/TLS transport layer. It is useful to to decrypt traffic + sent using ephemeral ciphers. This requires OpenSSL >= 1.1.0, or BoringSSL. + ssl_fc_session_id : binary Returns the SSL ID of the front connection when the incoming connection was made over an SSL/TLS transport layer. It is useful to stick a given client to diff --git a/src/ssl_sock.c b/src/ssl_sock.c index 2676fcd18..a007e9ab7 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -7195,6 +7195,37 @@ smp_fetch_ssl_fc_session_id(const struct arg *args, struct sample *smp, const ch #if HA_OPENSSL_VERSION_NUMBER >= 0x10100000L +static int +smp_fetch_ssl_fc_random(const struct arg *args, struct sample *smp, const char *kw, void *private) +{ + struct connection *conn = (kw[4] != 'b') ? objt_conn(smp->sess->origin) : + smp->strm ? cs_conn(objt_cs(smp->strm->si[1].end)) : NULL; + struct buffer *data; + struct ssl_sock_ctx *ctx; + + if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock) + return 0; + ctx = conn->xprt_ctx; + + data = get_trash_chunk(); + if (kw[7] == 'c') + data->data = SSL_get_client_random(ctx->ssl, + (unsigned char *) data->area, + data->size); + else + data->data = SSL_get_server_random(ctx->ssl, + (unsigned char *) data->area, + data->size); + if (!data->data) + return 0; + + smp->flags = 0; + smp->data.type = SMP_T_BIN; + smp->data.u.str = *data; + + return 1; +} + static int smp_fetch_ssl_fc_session_key(const struct arg *args, struct sample *smp, const char *kw, void *private) { @@ -9395,6 +9426,8 @@ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, { { "ssl_bc_session_id", smp_fetch_ssl_fc_session_id, 0, NULL, SMP_T_BIN, SMP_USE_L5SRV }, #endif #if HA_OPENSSL_VERSION_NUMBER >= 0x10100000L + { "ssl_bc_client_random", smp_fetch_ssl_fc_random, 0, NULL, SMP_T_BIN, SMP_USE_L5SRV }, + { "ssl_bc_server_random", smp_fetch_ssl_fc_random, 0, NULL, SMP_T_BIN, SMP_USE_L5SRV }, { "ssl_bc_session_key", smp_fetch_ssl_fc_session_key, 0, NULL, SMP_T_BIN, SMP_USE_L5SRV }, #endif { "ssl_c_ca_err", smp_fetch_ssl_c_ca_err, 0, NULL, SMP_T_SINT, SMP_USE_L5CLI }, @@ -9444,6 +9477,8 @@ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, { { "ssl_fc_session_id", smp_fetch_ssl_fc_session_id, 0, NULL, SMP_T_BIN, SMP_USE_L5CLI }, #endif #if HA_OPENSSL_VERSION_NUMBER >= 0x10100000L + { "ssl_fc_client_random", smp_fetch_ssl_fc_random, 0, NULL, SMP_T_BIN, SMP_USE_L5CLI }, + { "ssl_fc_server_random", smp_fetch_ssl_fc_random, 0, NULL, SMP_T_BIN, SMP_USE_L5CLI }, { "ssl_fc_session_key", smp_fetch_ssl_fc_session_key, 0, NULL, SMP_T_BIN, SMP_USE_L5CLI }, #endif #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME