@@ -358,6 +358,7 @@ int main(int argc, char *argv[])
358358 {"ssl-verify" , no_argument , NULL , 0 },
359359 {"ssl-trustfile" , required_argument , NULL , 0 },
360360 {"ssl-ciphers" , required_argument , NULL , 0 },
361+ {"ssl-servername" , required_argument , NULL , 0 },
361362 {"ssl-alpn" , required_argument , NULL , 0 },
362363#else
363364 {"ssl-cert" , optional_argument , NULL , 0 },
@@ -573,6 +574,9 @@ int main(int argc, char *argv[])
573574 } else if (strcmp (long_options [option_index ].name , "ssl - ciphers ") == 0 ) {
574575 o .ssl = 1 ;
575576 o .sslciphers = Strdup (optarg );
577+ } else if (strcmp (long_options [option_index ].name , "ssl - servername ") == 0 ) {
578+ o .ssl = 1 ;
579+ o .sslservername = Strdup (optarg );
576580#ifdef HAVE_ALPN_SUPPORT
577581 } else if (strcmp (long_options [option_index ].name , "ssl-alpn" ) == 0 ) {
578582 o .ssl = 1 ;
@@ -594,6 +598,8 @@ int main(int argc, char *argv[])
594598 bye ("OpenSSL isn't compiled in. The --ssl-trustfile option cannot be chosen." );
595599 } else if (strcmp (long_options [option_index ].name , "ssl - ciphers ") == 0) {
596600 bye ("OpenSSL isn't compiled in. The --ssl-ciphers option cannot be chosen." );
601+ } else if (strcmp (long_options [option_index ].name , "ssl-servername" ) == 0 ) {
602+ bye ("OpenSSL isn't compiled in. The --ssl-servername option cannot be chosen." );
597603 } else if (strcmp (long_options [option_index ].name , "ssl-alpn" ) == 0 ) {
598604 bye ("OpenSSL isn't compiled in. The --ssl-alpn option cannot be chosen." );
599605 }
@@ -695,7 +701,8 @@ int main(int argc, char *argv[])
695701" --ssl-verify Verify trust and domain name of certificates\n"
696702" --ssl-trustfile PEM file containing trusted SSL certificates\n"
697703" --ssl-ciphers Cipherlist containing SSL ciphers to use\n"
698- " --ssl-alpn ALPN protocol list to use.\n"
704+ " --ssl-servername Request distinct server name (SNI)\n"
705+ " --ssl-alpn ALPN protocol list to use\n"
699706#endif
700707" -- version Display Ncat 's version information and exit \n "
701708"\n "
@@ -943,6 +950,8 @@ int main(int argc, char *argv[])
943950 && (rc = resolve_multi (o .target , 0 , targetaddrs , o .af )) != 0 )
944951
945952 bye ("Could not resolve hostname \"%s\": %s." , o .target , gai_strerror (rc ));
953+ if (!o .sslservername )
954+ o .sslservername = o .target ;
946955 optind ++ ;
947956 } else {
948957 if (!o .listen )
0 commit comments