Fix gcc warnings.
[openssl.git] / apps / s_client.c
index 0afd7907a1fdb8723afc9b6104835e1a62a9448e..c4c3b0e94a59b6b6746bd2f061d0b719f35f2218 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
 
@@ -152,11 +148,13 @@ static void sc_usage(void)
        BIO_printf(bio_err," -tls1         - just use TLSv1\n");
        BIO_printf(bio_err," -no_tls1/-no_ssl3/-no_ssl2 - turn off that protocol\n");
        BIO_printf(bio_err," -bugs         - Switch on all SSL implementation bug workarounds\n");
-       BIO_printf(bio_err," -cipher       - prefered cipher to use, use the 'openssl ciphers'\n");
+       BIO_printf(bio_err," -cipher       - preferred cipher to use, use the 'openssl ciphers'\n");
        BIO_printf(bio_err,"                 command to see what is available\n");
 
        }
 
+int MAIN(int, char **);
+
 int MAIN(int argc, char **argv)
        {
        int off=0;
@@ -176,6 +174,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 +244,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)
@@ -338,7 +339,8 @@ bad:
                        }
                }
 
-       SSLeay_add_ssl_algorithms();
+       OpenSSL_add_ssl_algorithms();
+       SSL_load_error_strings();
        ctx=SSL_CTX_new(meth);
        if (ctx == NULL)
                {
@@ -353,7 +355,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 setting cipher list\n");
+               ERR_print_errors(bio_err);
+               goto end;
+       }
 #if 0
        else
                SSL_CTX_set_cipher_list(ctx,getenv("SSL_CIPHER"));
@@ -366,14 +372,13 @@ bad:
        if ((!SSL_CTX_load_verify_locations(ctx,CAfile,CApath)) ||
                (!SSL_CTX_set_default_verify_paths(ctx)))
                {
-               /* BIO_printf(bio_err,"error seting default verify locations\n"); */
+               /* BIO_printf(bio_err,"error setting default verify locations\n"); */
                ERR_print_errors(bio_err);
                /* goto end; */
                }
 
-       SSL_load_error_strings();
 
-       con=(SSL *)SSL_new(ctx);
+       con=SSL_new(ctx);
 /*     SSL_set_cipher_list(con,"RC4-MD5"); */
 
 re_start:
@@ -503,6 +508,7 @@ re_start:
                         * are any keypresses. Note: this is a hack, in a proper
                         * Windows application we wouldn't do this.
                         */
+                       i=0;
                        if(!write_tty) {
                                if(read_tty) {
                                        tv.tv_sec = 1;
@@ -735,12 +741,12 @@ 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);
        if (cbuf != NULL) { memset(cbuf,0,BUFSIZZ); Free(cbuf); }
        if (sbuf != NULL) { memset(sbuf,0,BUFSIZZ); Free(sbuf); }
-       X509_cleanup();
        if (bio_c_out != NULL)
                {
                BIO_free(bio_c_out);