Make s_server, s_client check cipher list return codes.
[openssl.git] / apps / s_client.c
index 60a8728c9bc837d4af966a8261b51a1d71de7458..c9b52e6a99ce651738f1c3a4eb9843fa0aa0e71a 100644 (file)
@@ -91,10 +91,6 @@ typedef unsigned int u_int;
 #undef FIONBIO
 #endif
 
-#if defined(NO_RSA) && !defined(NO_SSL2)
-#define NO_SSL2
-#endif
-
 #undef PROG
 #define PROG   s_client_main
 
@@ -176,6 +172,7 @@ int MAIN(int argc, char **argv)
        int write_tty,read_tty,write_ssl,read_ssl,tty_on,ssl_pending;
        SSL_CTX *ctx=NULL;
        int ret=1,in_init=1,i,nbio_test=0;
+       int prexit = 0;
        SSL_METHOD *meth=NULL;
        BIO *sbio;
 #ifdef WINDOWS
@@ -245,6 +242,8 @@ int MAIN(int argc, char **argv)
                        if (--argc < 1) goto bad;
                        cert_file= *(++argv);
                        }
+               else if (strcmp(*argv,"-prexit") == 0)
+                       prexit=1;
                else if (strcmp(*argv,"-crlf") == 0)
                        crlf=1;
                else if (strcmp(*argv,"-quiet") == 0)
@@ -339,6 +338,7 @@ bad:
                }
 
        SSLeay_add_ssl_algorithms();
+       SSL_load_error_strings();
        ctx=SSL_CTX_new(meth);
        if (ctx == NULL)
                {
@@ -353,7 +353,11 @@ bad:
 
        if (state) SSL_CTX_set_info_callback(ctx,apps_ssl_info_callback);
        if (cipher != NULL)
-               SSL_CTX_set_cipher_list(ctx,cipher);
+               if(!SSL_CTX_set_cipher_list(ctx,cipher)) {
+               BIO_printf(bio_err,"error seting cipher list\n");
+               ERR_print_errors(bio_err);
+               goto end;
+       }
 #if 0
        else
                SSL_CTX_set_cipher_list(ctx,getenv("SSL_CIPHER"));
@@ -371,7 +375,6 @@ bad:
                /* goto end; */
                }
 
-       SSL_load_error_strings();
 
        con=(SSL *)SSL_new(ctx);
 /*     SSL_set_cipher_list(con,"RC4-MD5"); */
@@ -735,6 +738,7 @@ shut:
        SHUTDOWN(SSL_get_fd(con));
        ret=0;
 end:
+       if(prexit) print_stuff(bio_c_out,con,1);
        if (con != NULL) SSL_free(con);
        if (con2 != NULL) SSL_free(con2);
        if (ctx != NULL) SSL_CTX_free(ctx);