X-Git-Url: https://git.openssl.org/gitweb/?a=blobdiff_plain;f=apps%2Fs_server.c;h=f544be15961c5a04a95879763db4283d81313819;hb=032c6d21fc53d5ec8b7ef78b0997627d1d240dad;hp=c28aa51d4058241583d49397574ff2113697bd85;hpb=ba8108154dafb081b510cc628783c6b44c95cb0e;p=openssl.git diff --git a/apps/s_server.c b/apps/s_server.c index c28aa51d40..f544be1596 100644 --- a/apps/s_server.c +++ b/apps/s_server.c @@ -244,6 +244,8 @@ static char *keymatexportlabel = NULL; static int keymatexportlen = 20; static int async = 0; +static unsigned int split_send_fragment = 0; +static unsigned int max_pipelines = 0; #ifndef OPENSSL_NO_ENGINE static char *engine_id = NULL; @@ -402,6 +404,8 @@ static void s_server_init(void) s_quiet = 0; s_brief = 0; async = 0; + split_send_fragment = 0; + max_pipelines = 0; #ifndef OPENSSL_NO_ENGINE engine_id = NULL; #endif @@ -805,7 +809,7 @@ typedef enum OPTION_choice { OPT_QUIET, OPT_BRIEF, OPT_NO_DHE, OPT_NO_RESUME_EPHEMERAL, OPT_PSK_HINT, OPT_PSK, OPT_SRPVFILE, OPT_SRPUSERSEED, OPT_REV, OPT_WWW, OPT_UPPER_WWW, OPT_HTTP, OPT_ASYNC, - OPT_SSL_CONFIG, OPT_SSL3, + OPT_SSL_CONFIG, OPT_SPLIT_SEND_FRAG, OPT_MAX_PIPELINES, OPT_SSL3, OPT_TLS1_2, OPT_TLS1_1, OPT_TLS1, OPT_DTLS, OPT_DTLS1, OPT_DTLS1_2, OPT_TIMEOUT, OPT_MTU, OPT_CHAIN, OPT_LISTEN, OPT_ID_PREFIX, OPT_RAND, OPT_SERVERNAME, OPT_SERVERNAME_FATAL, @@ -938,6 +942,10 @@ OPTIONS s_server_options[] = { {"async", OPT_ASYNC, '-', "Operate in asynchronous mode"}, {"ssl_config", OPT_SSL_CONFIG, 's', \ "Configure SSL_CTX using the configuration 'val'"}, + {"split_send_frag", OPT_SPLIT_SEND_FRAG, 'n', + "Size used to split data for encrypt/decrypt pipelines"}, + {"max_pipelines", OPT_MAX_PIPELINES, 'n', + "Maximum number of encrypt/decrypt pipelines to be used"}, OPT_S_OPTIONS, OPT_V_OPTIONS, OPT_X_OPTIONS, @@ -987,9 +995,9 @@ OPTIONS s_server_options[] = { #ifndef OPENSSL_NO_SRTP {"use_srtp", OPT_SRTP_PROFILES, 's', "Offer SRTP key management with a colon-separated profile list"}, +#endif {"alpn", OPT_ALPN, 's', "Set the advertised protocols for the ALPN extension (comma-separated list)"}, -#endif #ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, #endif @@ -1332,9 +1340,8 @@ int s_server_main(int argc, char *argv[]) case OPT_TRACE: #ifndef OPENSSL_NO_SSL_TRACE s_msg = 2; -#else - break; #endif + break; case OPT_SECURITY_DEBUG: sdebug = 1; break; @@ -1491,7 +1498,9 @@ int s_server_main(int argc, char *argv[]) alpn_in = opt_arg(); break; case OPT_SRTP_PROFILES: +#ifndef OPENSSL_NO_SRTP srtp_profiles = opt_arg(); +#endif break; case OPT_KEYMATEXPORT: keymatexportlabel = opt_arg(); @@ -1502,6 +1511,16 @@ int s_server_main(int argc, char *argv[]) case OPT_ASYNC: async = 1; break; + case OPT_SPLIT_SEND_FRAG: + split_send_fragment = atoi(opt_arg()); + if (split_send_fragment == 0) { + /* Not allowed - set to a deliberately bad value */ + split_send_fragment = -1; + } + break; + case OPT_MAX_PIPELINES: + max_pipelines = atoi(opt_arg()); + break; } } argc = opt_num_rest(); @@ -1527,6 +1546,16 @@ int s_server_main(int argc, char *argv[]) } #endif + if (split_send_fragment > SSL3_RT_MAX_PLAIN_LENGTH) { + BIO_printf(bio_err, "Bad split send fragment size\n"); + goto end; + } + + if (max_pipelines > SSL_MAX_PIPELINES) { + BIO_printf(bio_err, "Bad max pipelines value\n"); + goto end; + } + if (!app_passwd(passarg, dpassarg, &pass, &dpass)) { BIO_printf(bio_err, "Error getting password\n"); goto end; @@ -1717,6 +1746,12 @@ int s_server_main(int argc, char *argv[]) if (async) { SSL_CTX_set_mode(ctx, SSL_MODE_ASYNC); } + if (split_send_fragment > 0) { + SSL_CTX_set_split_send_fragment(ctx, split_send_fragment); + } + if (max_pipelines > 0) { + SSL_CTX_set_max_pipelines(ctx, max_pipelines); + } #ifndef OPENSSL_NO_SRTP if (srtp_profiles != NULL) { @@ -2244,7 +2279,7 @@ static int sv_body(int s, int stype, unsigned char *context) if ((i <= 0) || (buf[0] == 'Q')) { BIO_printf(bio_s_out, "DONE\n"); (void)BIO_flush(bio_s_out); - SHUTDOWN(s); + BIO_closesocket(s); close_accept_socket(); ret = -11; goto err; @@ -2253,7 +2288,7 @@ static int sv_body(int s, int stype, unsigned char *context) BIO_printf(bio_s_out, "DONE\n"); (void)BIO_flush(bio_s_out); if (SSL_version(con) != DTLS1_VERSION) - SHUTDOWN(s); + BIO_closesocket(s); /* * close_accept_socket(); ret= -11; */ @@ -2450,7 +2485,7 @@ static void close_accept_socket(void) { BIO_printf(bio_err, "shutdown accept socket\n"); if (accept_socket >= 0) { - SHUTDOWN2(accept_socket); + BIO_closesocket(accept_socket); } }