Skip to content

Commit

Permalink
mod_ssl: Add SSL_HANDSHAKE_RTT environment variable.
Browse files Browse the repository at this point in the history
* modules/ssl/ssl_engine_vars.c (ssl_var_lookup_ssl): Support
  SSL_HANDSHAKE_RTT.  (ssl_var_lookup_ssl_handshake_rtt): New
  function.

* modules/ssl/ssl_engine_kernel.c (ssl_hook_Fixup_vars): Add
  SSL_HANDSHAKE_RTT.

Submitted by: csmutz
Github: closes #477


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1920297 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
notroj committed Aug 30, 2024
1 parent 1bce53d commit 79990b0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions changes-entries/ssl-handshake-rtt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*) mod_ssl: Add SSL_HANDSHAKE_RTT environment variable. [csmutz]
1 change: 1 addition & 0 deletions docs/manual/mod/mod_ssl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ compatibility variables.</p>
<tr><td><code>SSL_SRP_USER</code></td> <td>string</td> <td>SRP username</td></tr>
<tr><td><code>SSL_SRP_USERINFO</code></td> <td>string</td> <td>SRP user info</td></tr>
<tr><td><code>SSL_TLS_SNI</code></td> <td>string</td> <td>Contents of the SNI TLS extension (if supplied with ClientHello)</td></tr>
<tr><td><code>SSL_HANDSHAKE_RTT</code></td> <td>number</td> <td>Round-trip time of TLS handshake in microseconds including endpoint processing (set to empty string if OpenSSL version prior to 3.2 or if round-trip time can not be determined)</td></tr>
</table>

<p><em>x509</em> specifies a component of an X.509 DN; one of
Expand Down
1 change: 1 addition & 0 deletions modules/ssl/ssl_engine_kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,7 @@ static const char *const ssl_hook_Fixup_vars[] = {
"SSL_SRP_USER",
"SSL_SRP_USERINFO",
#endif
"SSL_HANDSHAKE_RTT",
NULL
};

Expand Down
14 changes: 14 additions & 0 deletions modules/ssl/ssl_engine_vars.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static const char *ssl_var_lookup_ssl_cert_rfc4523_cea(apr_pool_t *p, SSL *ssl);
static const char *ssl_var_lookup_ssl_cert_verify(apr_pool_t *p, const SSLConnRec *sslconn);
static const char *ssl_var_lookup_ssl_cipher(apr_pool_t *p, const SSLConnRec *sslconn, const char *var);
static void ssl_var_lookup_ssl_cipher_bits(SSL *ssl, int *usekeysize, int *algkeysize);
static const char *ssl_var_lookup_ssl_handshake_rtt(apr_pool_t *p, SSL *ssl);
static const char *ssl_var_lookup_ssl_version(const char *var);
static const char *ssl_var_lookup_ssl_compress_meth(SSL *ssl);

Expand Down Expand Up @@ -472,6 +473,9 @@ static const char *ssl_var_lookup_ssl(apr_pool_t *p, const SSLConnRec *sslconn,
else if (ssl != NULL && strlen(var) >= 6 && strcEQn(var, "CIPHER", 6)) {
result = ssl_var_lookup_ssl_cipher(p, sslconn, var+6);
}
else if (ssl != NULL && strcEQ(var, "HANDSHAKE_RTT")) {
result = ssl_var_lookup_ssl_handshake_rtt(p, ssl);
}
else if (ssl != NULL && strlen(var) > 18 && strcEQn(var, "CLIENT_CERT_CHAIN_", 18)) {
sk = SSL_get_peer_cert_chain(ssl);
result = ssl_var_lookup_ssl_cert_chain(p, sk, var+18, 1);
Expand Down Expand Up @@ -961,6 +965,16 @@ static void ssl_var_lookup_ssl_cipher_bits(SSL *ssl, int *usekeysize, int *algke
return;
}

static const char *ssl_var_lookup_ssl_handshake_rtt(apr_pool_t *p, SSL *ssl)
{
#if OPENSSL_VERSION_NUMBER >= 0x30200000L
apr_uint64_t rtt;
if (SSL_get_handshake_rtt(ssl, &rtt) > 0)
return apr_psprintf(p, "%" APR_UINT64_T_FMT, rtt);
#endif
return NULL;
}

static const char *ssl_var_lookup_ssl_version(const char *var)
{
if (strEQ(var, "INTERFACE")) {
Expand Down

0 comments on commit 79990b0

Please sign in to comment.