summaryrefslogtreecommitdiffstats
path: root/apps/s_client.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2015-02-13 23:33:12 +0000
committerMatt Caswell <matt@openssl.org>2015-11-20 23:31:42 +0000
commit7e25dd6da17eefb3c0c31ac4ad436b70f6d39f86 (patch)
treed04613167538e7216a84bf856396f99bafe09868 /apps/s_client.c
parent07bbc92ccb96d48044220d2ed2cf818323baeb26 (diff)
Add s_server and s_client async support
A new -async option is added which activates SSL_MODE_ASYNC. Also SSL_WANT_ASYNC errors are handled appropriately. Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'apps/s_client.c')
-rw-r--r--apps/s_client.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/apps/s_client.c b/apps/s_client.c
index 94f2a94137..fa91eece02 100644
--- a/apps/s_client.c
+++ b/apps/s_client.c
@@ -182,6 +182,7 @@ extern int verify_error;
extern int verify_return_error;
extern int verify_quiet;
+static int async = 0;
static int c_nbio = 0;
static int c_tlsextdebug = 0;
static int c_status_req = 0;
@@ -472,6 +473,7 @@ typedef enum OPTION_choice {
OPT_CHAINCAFILE, OPT_VERIFYCAFILE, OPT_NEXTPROTONEG, OPT_ALPN,
OPT_SERVERINFO, OPT_STARTTLS, OPT_SERVERNAME, OPT_JPAKE,
OPT_USE_SRTP, OPT_KEYMATEXPORT, OPT_KEYMATEXPORTLEN, OPT_SMTPHOST,
+ OPT_ASYNC,
OPT_V_ENUM,
OPT_X_ENUM,
OPT_S_ENUM,
@@ -557,6 +559,7 @@ OPTIONS s_client_options[] = {
"types Send empty ClientHello extensions (comma-separated numbers)"},
{"alpn", OPT_ALPN, 's',
"Enable ALPN extension, considering named protocols supported (comma-separated list)"},
+ {"async", OPT_ASYNC, '-', "Support asynchronous operation"},
OPT_S_OPTIONS,
OPT_V_OPTIONS,
OPT_X_OPTIONS,
@@ -1061,6 +1064,9 @@ int s_client_main(int argc, char **argv)
case OPT_KEYMATEXPORTLEN:
keymatexportlen = atoi(opt_arg());
break;
+ case OPT_ASYNC:
+ async = 1;
+ break;
}
}
argc = opt_num_rest();
@@ -1199,6 +1205,9 @@ int s_client_main(int argc, char **argv)
goto end;
}
+ if (async)
+ SSL_CTX_set_mode(ctx, SSL_MODE_ASYNC);
+
if (!config_ctx(cctx, ssl_args, ctx, 1, jpake_secret == NULL))
goto end;
@@ -1883,6 +1892,11 @@ int s_client_main(int argc, char **argv)
write_ssl = 1;
read_tty = 0;
break;
+ case SSL_ERROR_WANT_ASYNC:
+ BIO_printf(bio_c_out, "write A BLOCK\n");
+ write_ssl = 1;
+ read_tty = 0;
+ break;
case SSL_ERROR_WANT_READ:
BIO_printf(bio_c_out, "write R BLOCK\n");
write_tty = 0;
@@ -1965,6 +1979,13 @@ int s_client_main(int argc, char **argv)
read_ssl = 0;
write_tty = 1;
break;
+ case SSL_ERROR_WANT_ASYNC:
+ BIO_printf(bio_c_out, "read A BLOCK\n");
+ write_tty = 0;
+ read_ssl = 1;
+ if ((read_tty == 0) && (write_ssl == 0))
+ write_ssl = 1;
+ break;
case SSL_ERROR_WANT_WRITE:
BIO_printf(bio_c_out, "read W BLOCK\n");
write_ssl = 1;