ssl_fc_has_hrr returns true when a HelloRetryRequest was sent to the
client during the handshake, and ssl_bc_has_hrr when one was received
from the server. They rely on the SSL_SOCK_F_HRR flag added by the
previous commit.
This may be used to log how many clients need one more round trip
because of the configured curves, for example:
log-format "... %[ssl_fc_curve] %[ssl_fc_has_hrr]"
They are not available with wolfSSL, for which the message callback is
not set.
---
doc/configuration.txt | 22 ++++++++++++++++++++++
src/ssl_sample.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+)
diff --git a/doc/configuration.txt b/doc/configuration.txt
index c5beca38f..fb4e9c0a3 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -27600,6 +27600,7 @@ ssl_bc_early_exporter_secret
string
ssl_bc_err integer
ssl_bc_err_str string
ssl_bc_exporter_secret string
+ssl_bc_has_hrr boolean
ssl_bc_is_resumed boolean
ssl_bc_npn string
ssl_bc_protocol string
@@ -27663,6 +27664,7 @@ ssl_fc_exporter_secret
string
ssl_fc_extlist_bin([<filter_option>]) binary
ssl_fc_has_crt boolean
ssl_fc_has_early boolean
+ssl_fc_has_hrr boolean
ssl_fc_has_sni boolean
ssl_fc_is_resumed boolean
ssl_fc_npn string
@@ -27939,6 +27941,15 @@ ssl_bc_exporter_secret : string
activated with "tune.ssl.keylog on" in the global section. See also
"tune.ssl.keylog"
+ssl_bc_has_hrr : boolean
+ Returns true when the outgoing connection was made over a TLS 1.3 transport
+ layer and a HelloRetryRequest was received from the server during the
+ handshake. It can be used in a tcp-check or an http-check ruleset. See also
+ "ssl_fc_has_hrr".
+
+ Compatibility: OpenSSL >= 1.1.1, AWS-LC >= 1.22.0 (API >= 22). Not supported
+ with wolfSSL.
+
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
@@ -28525,6 +28536,17 @@ ssl_fc_has_early : boolean
wait until the handshake completes (via the "wait-for-handshake" action). See
also "ssl_fc_early_rcvd".
+ssl_fc_has_hrr : boolean
+ Returns true when the incoming connection was made over a TLS 1.3 transport
+ layer and a HelloRetryRequest was sent to the client during the handshake.
+ This happens when the client sent no key share for the group which was
+ chosen (see the "curves" keyword of the "bind" lines), and costs one more
+ round trip. It may be used to know how many clients are affected, for
+ example once a post-quantum group is preferred.
+
+ Compatibility: OpenSSL >= 1.1.1, AWS-LC >= 1.22.0 (API >= 22). Not supported
+ with wolfSSL.
+
ssl_fc_has_sni : boolean
This checks for the presence of a Server Name Indication TLS extension (SNI)
in an incoming connection was made over an SSL/TLS transport layer. Returns
diff --git a/src/ssl_sample.c b/src/ssl_sample.c
index 6cae7d8f6..50d17adeb 100644
--- a/src/ssl_sample.c
+++ b/src/ssl_sample.c
@@ -1721,6 +1721,33 @@ smp_fetch_ssl_fc_is_resumed(const struct arg *args,
struct sample *smp, const ch
return 1;
}
+/* boolean, returns true if a HelloRetryRequest was sent to the client during
+ * the handshake.
+ * This function is also usable on backend conn if the fetch keyword 5th
+ * char is 'b', in which case it tells if one was received from the server.
+ * The flag is set from the message callback, hence the condition.
+ */
+#ifdef SSL_CTRL_SET_MSG_CALLBACK
+static int
+smp_fetch_ssl_fc_has_hrr(const struct arg *args, struct sample *smp, const
char *kw, void *private)
+{
+ struct connection *conn;
+ struct ssl_sock_ctx *ctx;
+
+ if (obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
+ conn = (kw[4] == 'b') ?
sc_conn(__objt_check(smp->sess->origin)->sc) : NULL;
+ else
+ conn = (kw[4] != 'b') ? objt_conn(smp->sess->origin) :
+ smp->strm ? sc_conn(smp->strm->scb) : NULL;
+
+ ctx = conn_get_ssl_sock_ctx(conn);
+
+ smp->data.type = SMP_T_BOOL;
+ smp->data.u.sint = ctx && (ctx->flags & SSL_SOCK_F_HRR);
+ return 1;
+}
+#endif
+
/*
* string, returns the EC curve used for key agreement on the
* front and backend connection.
@@ -2821,6 +2848,9 @@ static struct sample_fetch_kw_list sample_fetch_keywords
= {ILH, {
#endif
#if defined(OPENSSL_NPN_NEGOTIATED) && !defined(OPENSSL_NO_NEXTPROTONEG)
{ "ssl_bc_npn", smp_fetch_ssl_fc_npn, 0,
NULL, SMP_T_STR, SMP_USE_L5SRV },
+#endif
+#ifdef SSL_CTRL_SET_MSG_CALLBACK
+ { "ssl_bc_has_hrr", smp_fetch_ssl_fc_has_hrr, 0,
NULL, SMP_T_BOOL, SMP_USE_L5SRV },
#endif
{ "ssl_bc_is_resumed", smp_fetch_ssl_fc_is_resumed, 0,
NULL, SMP_T_BOOL, SMP_USE_L5SRV },
{ "ssl_bc_protocol", smp_fetch_ssl_fc_protocol, 0,
NULL, SMP_T_STR, SMP_USE_L5SRV },
@@ -2888,6 +2918,9 @@ static struct sample_fetch_kw_list sample_fetch_keywords
= {ILH, {
{ "ssl_fc_early_rcvd", smp_fetch_ssl_fc_early_rcvd, 0,
NULL, SMP_T_BOOL, SMP_USE_L5CLI },
{ "ssl_fc_has_crt", smp_fetch_ssl_fc_has_crt, 0,
NULL, SMP_T_BOOL, SMP_USE_L5CLI },
{ "ssl_fc_has_early", smp_fetch_ssl_fc_has_early, 0,
NULL, SMP_T_BOOL, SMP_USE_L5CLI },
+#ifdef SSL_CTRL_SET_MSG_CALLBACK
+ { "ssl_fc_has_hrr", smp_fetch_ssl_fc_has_hrr, 0,
NULL, SMP_T_BOOL, SMP_USE_L5CLI },
+#endif
{ "ssl_fc_has_sni", smp_fetch_ssl_fc_has_sni, 0,
NULL, SMP_T_BOOL, SMP_USE_L5CLI },
{ "ssl_fc_is_resumed", smp_fetch_ssl_fc_is_resumed, 0,
NULL, SMP_T_BOOL, SMP_USE_L5CLI },
#if defined(OPENSSL_NPN_NEGOTIATED) && !defined(OPENSSL_NO_NEXTPROTONEG)
--
2.50.1 (Apple Git-155)