The EVP_*Init_ex() functions take one extra argument. Let's default
[openssl.git] / apps / s_client.c
index bad59f64683601aa848fad16419faac3b6fba815..2c9ae354627f71c9ad1d3d89b616e72b574bddca 100644 (file)
@@ -80,7 +80,7 @@ typedef unsigned int u_int;
 #include <openssl/ssl.h>
 #include <openssl/err.h>
 #include <openssl/pem.h>
-#include <openssl/engine.h>
+#include <openssl/rand.h>
 #include "s_apps.h"
 
 #ifdef OPENSSL_SYS_WINDOWS
@@ -382,28 +382,7 @@ bad:
        OpenSSL_add_ssl_algorithms();
        SSL_load_error_strings();
 
-       if (engine_id != NULL)
-               {
-               if((e = ENGINE_by_id(engine_id)) == NULL)
-                       {
-                       BIO_printf(bio_err,"invalid engine\n");
-                       ERR_print_errors(bio_err);
-                       goto end;
-                       }
-               if (c_debug)
-                       {
-                       ENGINE_ctrl(e, ENGINE_CTRL_SET_LOGSTREAM,
-                               0, bio_err, 0);
-                       }
-               if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
-                       {
-                       BIO_printf(bio_err,"can't use that engine\n");
-                       ERR_print_errors(bio_err);
-                       goto end;
-                       }
-               BIO_printf(bio_err,"engine \"%s\" set.\n", engine_id);
-               ENGINE_free(e);
-               }
+        e = setup_engine(bio_err, engine_id, 1);
 
        ctx=SSL_CTX_new(meth);
        if (ctx == NULL)
@@ -824,6 +803,7 @@ end:
                BIO_free(bio_c_out);
                bio_c_out=NULL;
                }
+       apps_shutdown();
        EXIT(ret);
        }
 
@@ -945,5 +925,7 @@ static void print_stuff(BIO *bio, SSL *s, int full)
        BIO_printf(bio,"---\n");
        if (peer != NULL)
                X509_free(peer);
+       /* flush, or debugging output gets mixed with http response */
+       BIO_flush(bio);
        }