]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
OPTIM: backend: Don't set SNI for non-ssl connections
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 3 Sep 2025 14:44:15 +0000 (16:44 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 5 Sep 2025 13:56:42 +0000 (15:56 +0200)
There is no reason to set the SNI for non-ssl connections. It is not really
an issue because ssl_sock_set_servername() function will do nothing. But
there is no reason to uselessly evaluate an expression.

No backport needed, because there is no bug.

src/backend.c

index aa5052936802e3013fb4b7e01bc5c80fcbaed01f..00c85a401a26f3b2d306e4b58b6139683c13be81 100644 (file)
@@ -2107,7 +2107,7 @@ int connect_server(struct stream *s)
 
 #ifdef USE_OPENSSL
        /* Set socket SNI unless connection is reused. */
-       if (srv && srv->ssl_ctx.sni && !(s->flags & SF_SRV_REUSED)) {
+       if (conn_is_ssl(srv_conn) && srv && srv->ssl_ctx.sni && !(s->flags & SF_SRV_REUSED)) {
                struct sample *sni_smp = NULL;
 
                sni_smp = sample_fetch_as_type(s->be, s->sess, s,