Skip to content

Commit

Permalink
Ensure s_client sends SNI data when used with -proxy
Browse files Browse the repository at this point in the history
The use of -proxy prevented s_client from correctly sending the target
hostname as SNI data.

Fixes #17232

Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from #17248)

(cherry picked from commit ea24196)
  • Loading branch information
mattcaswell committed Dec 29, 2021
1 parent db82fa2 commit 5713edd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apps/s_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@ int s_client_main(int argc, char **argv)
struct timeval tv;
#endif
const char *servername = NULL;
char *sname_alloc = NULL;
int noservername = 0;
const char *alpn_in = NULL;
tlsextctx tlsextcbp = { NULL, 0 };
Expand Down Expand Up @@ -1530,6 +1531,14 @@ int s_client_main(int argc, char **argv)
goto opthelp;
}

if (servername == NULL && !noservername) {
servername = sname_alloc = OPENSSL_strdup(host);
if (sname_alloc == NULL) {
BIO_printf(bio_err, "%s: out of memory\n", prog);
goto end;
}
}

/* Retain the original target host:port for use in the HTTP proxy connect string */
thost = OPENSSL_strdup(host);
tport = OPENSSL_strdup(port);
Expand Down Expand Up @@ -3038,6 +3047,7 @@ int s_client_main(int argc, char **argv)
#ifndef OPENSSL_NO_SRP
OPENSSL_free(srp_arg.srppassin);
#endif
OPENSSL_free(sname_alloc);
OPENSSL_free(connectstr);
OPENSSL_free(bindstr);
OPENSSL_free(bindhost);
Expand Down

0 comments on commit 5713edd

Please sign in to comment.