X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=apps%2Fs_client.c;h=975aa2fb447353a08250b37d9f016ed7d08a691c;hp=45464a4ca981d23e296d984feede74ec8f5cd6c4;hb=dd5b98c55a64f574958a1a8aef2546692ff30ad9;hpb=3ee1eac27a2e3120fbdc60e12db091c082b8de21 diff --git a/apps/s_client.c b/apps/s_client.c index 45464a4ca9..975aa2fb44 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -8,6 +8,7 @@ * https://www.openssl.org/source/license.html */ +#include "e_os.h" #include #include #include @@ -28,7 +29,6 @@ typedef unsigned int u_int; #endif -#define USE_SOCKETS #include "apps.h" #include #include @@ -46,6 +46,7 @@ typedef unsigned int u_int; #endif #include "s_apps.h" #include "timeouts.h" +#include "internal/sockets.h" #if defined(__has_feature) # if __has_feature(memory_sanitizer) @@ -1522,11 +1523,13 @@ int s_client_main(int argc, char **argv) } } +#ifdef AF_UNIX if (socket_family == AF_UNIX && socket_type != SOCK_STREAM) { BIO_printf(bio_err, "Can't use unix sockets and datagrams together\n"); goto end; } +#endif #ifndef OPENSSL_NO_SCTP if (protocol == IPPROTO_SCTP) { @@ -1885,6 +1888,26 @@ int s_client_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } + /* By default the SNI should be the same as was set in the session */ + if (!noservername && servername == NULL) + { + const char *sni = SSL_SESSION_get0_hostname(sess); + + if (sni != NULL) { + servername = OPENSSL_strdup(sni); + if (servername == NULL) { + BIO_printf(bio_err, "Can't set server name\n"); + ERR_print_errors(bio_err); + goto end; + } + } else { + /* + * Force no SNI to be sent so we are consistent with the + * session. + */ + noservername = 1; + } + } SSL_SESSION_free(sess); } @@ -2597,8 +2620,10 @@ int s_client_main(int argc, char **argv) } if (early_data_file != NULL - && SSL_get0_session(con) != NULL - && SSL_SESSION_get_max_early_data(SSL_get0_session(con)) > 0) { + && ((SSL_get0_session(con) != NULL + && SSL_SESSION_get_max_early_data(SSL_get0_session(con)) > 0) + || (psksess != NULL + && SSL_SESSION_get_max_early_data(psksess) > 0))) { BIO *edfile = BIO_new_file(early_data_file, "r"); size_t readbytes, writtenbytes; int finish = 0; @@ -2622,6 +2647,7 @@ int s_client_main(int argc, char **argv) default: BIO_printf(bio_err, "Error writing early data\n"); BIO_free(edfile); + ERR_print_errors(bio_err); goto shut; } }