diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2021-01-28 14:31:38 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2021-01-28 14:31:38 +0000 |
commit | e75d06de207e9afe4259d5e731cb77ae25faf003 (patch) | |
tree | 3a3e3d6dee626f2a6640daaaf6871880d50a8184 /src/sbearssl | |
parent | a027959a7fe49483acf86bd65d4266e3cbc4d0b0 (diff) | |
download | s6-networking-e75d06de207e9afe4259d5e731cb77ae25faf003.tar.xz |
Remove SSL_TLS_SNI_SERVERNAME (instead of defined but empty) if no SNI
Diffstat (limited to 'src/sbearssl')
-rw-r--r-- | src/sbearssl/sbearssl_send_environment.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/sbearssl/sbearssl_send_environment.c b/src/sbearssl/sbearssl_send_environment.c index 2439351..bb0fb35 100644 --- a/src/sbearssl/sbearssl_send_environment.c +++ b/src/sbearssl/sbearssl_send_environment.c @@ -12,6 +12,7 @@ int sbearssl_send_environment (br_ssl_engine_context *ctx, int fd) char buf[4096] ; buffer b = BUFFER_INIT(&buffer_write, fd, buf, 4096) ; unsigned int v = br_ssl_engine_get_version(ctx) ; + char const *name = br_ssl_engine_get_server_name(ctx) ; char const *suite ; br_ssl_session_parameters params ; @@ -26,9 +27,15 @@ int sbearssl_send_environment (br_ssl_engine_context *ctx, int fd) || buffer_puts(&b, "SSL_CIPHER=") < 0 || buffer_puts(&b, suite) < 0 || buffer_put(&b, "", 1) < 0 - || buffer_puts(&b, "SSL_TLS_SNI_SERVERNAME=") < 0 - || buffer_puts(&b, br_ssl_engine_get_server_name(ctx)) < 0 - || buffer_putflush(&b, "\0", 2) < 0) + || buffer_puts(&b, "SSL_TLS_SNI_SERVERNAME") < 0) + return 0 ; + if (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 ; } |