Not all 'find's know -xtype, use -type instead
[openssl.git] / apps / s_client.c
index fa91eece02168fbe876b563496715b06b29a495f..e3ab42b5349967b1640f4e06beb21a6d503073a7 100644 (file)
@@ -160,6 +160,7 @@ typedef unsigned int u_int;
 #include <openssl/rand.h>
 #include <openssl/ocsp.h>
 #include <openssl/bn.h>
+#include <openssl/async.h>
 #ifndef OPENSSL_NO_SRP
 # include <openssl/srp.h>
 #endif
@@ -1205,8 +1206,10 @@ int s_client_main(int argc, char **argv)
         goto end;
     }
 
-    if (async)
+    if (async) {
         SSL_CTX_set_mode(ctx, SSL_MODE_ASYNC);
+        ASYNC_init(1, 0, 0);
+    }
 
     if (!config_ctx(cctx, ssl_args, ctx, 1, jpake_secret == NULL))
         goto end;
@@ -1510,8 +1513,8 @@ int s_client_main(int argc, char **argv)
             BIO_free(fbio);
             if (!foundit)
                 BIO_printf(bio_err,
-                           "didn't found starttls in server response,"
-                           " try anyway...\n");
+                           "didn't find starttls in server response,"
+                           " trying anyway...\n");
             BIO_printf(sbio, "STARTTLS\r\n");
             BIO_read(sbio, sbuf, BUFSIZZ);
         }
@@ -1548,8 +1551,8 @@ int s_client_main(int argc, char **argv)
             BIO_free(fbio);
             if (!foundit)
                 BIO_printf(bio_err,
-                           "didn't found STARTTLS in server response,"
-                           " try anyway...\n");
+                           "didn't find STARTTLS in server response,"
+                           " trying anyway...\n");
             BIO_printf(sbio, ". STARTTLS\r\n");
             BIO_read(sbio, sbuf, BUFSIZZ);
         }
@@ -1894,6 +1897,7 @@ int s_client_main(int argc, char **argv)
                 break;
             case SSL_ERROR_WANT_ASYNC:
                 BIO_printf(bio_c_out, "write A BLOCK\n");
+                wait_for_async(con);
                 write_ssl = 1;
                 read_tty = 0;
                 break;
@@ -1981,6 +1985,7 @@ int s_client_main(int argc, char **argv)
                 break;
             case SSL_ERROR_WANT_ASYNC:
                 BIO_printf(bio_c_out, "read A BLOCK\n");
+                wait_for_async(con);
                 write_tty = 0;
                 read_ssl = 1;
                 if ((read_tty == 0) && (write_ssl == 0))
@@ -2096,6 +2101,9 @@ int s_client_main(int argc, char **argv)
             print_stuff(bio_c_out, con, 1);
         SSL_free(con);
     }
+    if (async) {
+        ASYNC_cleanup(1);
+    }
 #if !defined(OPENSSL_NO_NEXTPROTONEG)
     OPENSSL_free(next_proto.data);
 #endif