From fb8ac46add99338d5c706555e2621d880f0c1090 Mon Sep 17 00:00:00 2001 From: Xiaokang Qian Date: Sat, 8 Oct 2022 11:09:54 +0000 Subject: [PATCH] Change the name of servername when re-connect Signed-off-by: Xiaokang Qian --- programs/ssl/ssl_client2.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index bc9335270..a7705ac9f 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -366,7 +366,6 @@ int main( void ) "\n usage: ssl_client2 param=<>...\n" \ "\n acceptable parameters:\n" \ " server_name=%%s default: localhost\n" \ - " rec_server_name=%%s default: localhost\n" \ " server_addr=%%s default: given by name\n" \ " server_port=%%d default: 4433\n" \ " request_page=%%s default: \".\"\n" \ @@ -406,6 +405,7 @@ int main( void ) " exchanges=%%d default: 1\n" \ " reconnect=%%d number of reconnections using session resumption\n" \ " default: 0 (disabled)\n" \ + " reco_server_name=%%s default: localhost\n" \ " reco_delay=%%d default: 0 seconds\n" \ " reco_mode=%%d 0: copy session, 1: serialize session\n" \ " default: 1\n" \ @@ -456,7 +456,6 @@ int main( void ) struct options { const char *server_name; /* hostname of the server (client only) */ - const char *rec_s_name; /* hostname of the server (re-connect) */ const char *server_addr; /* address of the server (client only) */ const char *server_port; /* port on which the ssl service runs */ int debug_level; /* level of debugging */ @@ -500,6 +499,7 @@ struct options int recsplit; /* enable record splitting? */ int dhmlen; /* minimum DHM params len in bits */ int reconnect; /* attempt to resume session */ + const char *reco_server_name; /* hostname of the server (re-connect) */ int reco_delay; /* delay in seconds before resuming session */ int reco_mode; /* how to keep the session around */ int reconnect_hard; /* unexpectedly reconnect from the same port */ @@ -878,7 +878,6 @@ int main( int argc, char *argv[] ) } opt.server_name = DFL_SERVER_NAME; - opt.rec_s_name = DFL_SERVER_NAME; opt.server_addr = DFL_SERVER_ADDR; opt.server_port = DFL_SERVER_PORT; opt.debug_level = DFL_DEBUG_LEVEL; @@ -926,6 +925,7 @@ int main( int argc, char *argv[] ) opt.recsplit = DFL_RECSPLIT; opt.dhmlen = DFL_DHMLEN; opt.reconnect = DFL_RECONNECT; + opt.reco_server_name = DFL_SERVER_NAME; opt.reco_delay = DFL_RECO_DELAY; opt.reco_mode = DFL_RECO_MODE; opt.reconnect_hard = DFL_RECONNECT_HARD; @@ -964,8 +964,6 @@ int main( int argc, char *argv[] ) if( strcmp( p, "server_name" ) == 0 ) opt.server_name = q; - else if( strcmp( p, "rec_server_name" ) == 0 ) - opt.rec_s_name = q; else if( strcmp( p, "server_addr" ) == 0 ) opt.server_addr = q; else if( strcmp( p, "server_port" ) == 0 ) @@ -1124,6 +1122,8 @@ int main( int argc, char *argv[] ) if( opt.reconnect < 0 || opt.reconnect > 2 ) goto usage; } + else if( strcmp( p, "rec_server_name" ) == 0 ) + opt.reco_server_name = q; else if( strcmp( p, "reco_delay" ) == 0 ) { opt.reco_delay = atoi( q ); @@ -3120,7 +3120,7 @@ reconnect: #if defined(MBEDTLS_X509_CRT_PARSE_C) if( ( ret = mbedtls_ssl_reset_hostname( &ssl, opt.server_name, - opt.rec_s_name ) ) != 0 ) + opt.reco_server_name ) ) != 0 ) { mbedtls_printf( " failed\n ! mbedtls_ssl_reset_hostname returned %d\n\n", ret );