summaryrefslogtreecommitdiff
path: root/src/stls/stls_send_environment.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-01-28 14:31:38 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2021-01-28 14:31:38 +0000
commite75d06de207e9afe4259d5e731cb77ae25faf003 (patch)
tree3a3e3d6dee626f2a6640daaaf6871880d50a8184 /src/stls/stls_send_environment.c
parenta027959a7fe49483acf86bd65d4266e3cbc4d0b0 (diff)
downloads6-networking-e75d06de207e9afe4259d5e731cb77ae25faf003.tar.xz
Remove SSL_TLS_SNI_SERVERNAME (instead of defined but empty) if no SNI
Diffstat (limited to 'src/stls/stls_send_environment.c')
-rw-r--r--src/stls/stls_send_environment.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/stls/stls_send_environment.c b/src/stls/stls_send_environment.c
index af0eeb6..c7cb9c7 100644
--- a/src/stls/stls_send_environment.c
+++ b/src/stls/stls_send_environment.c
@@ -11,18 +11,23 @@
int stls_send_environment (struct tls *ctx, int fd)
{
- char const *servername = tls_conn_servername(ctx) ;
+ char const *name = tls_conn_servername(ctx) ;
char buf[4096] ;
buffer b = BUFFER_INIT(&buffer_write, fd, buf, 4096) ;
- if (!servername) servername = "" ;
if (buffer_puts(&b, "SSL_PROTOCOL=") < 0
|| buffer_puts(&b, tls_conn_version(ctx)) < 0
|| buffer_put(&b, "", 1) < 0
|| buffer_puts(&b, "SSL_CIPHER=") < 0
|| buffer_puts(&b, tls_conn_cipher(ctx)) < 0
|| buffer_put(&b, "", 1) < 0
- || buffer_puts(&b, "SSL_TLS_SNI_SERVERNAME=") < 0
- || buffer_puts(&b, servername) < 0
- || buffer_putflush(&b, "\0", 2) < 0) return 0 ;
+ || buffer_puts(&b, "SSL_TLS_SNI_SERVERNAME") < 0)
+ return 0 ;
+ if (name && name[0])
+ {
+ if (buffer_put(&b, "=", 1) < 0
+ || buffer_puts(&b, name) < 0)
+ return 0 ;
+ }
+ if (buffer_putflush(&b, "\0", 2) < 0) return 0 ;
return 1 ;
}