X-Git-Url: https://git.openssl.org/gitweb/?a=blobdiff_plain;f=crypto%2Fthreads%2Fmttest.c;h=100165948c028f9ff4d3380368c4b8474ebee169;hb=26a3a48d65c7464b400ec1de439994d7f0d25fed;hp=ff380908c154d0be3f9a3c87c7efe221f087848a;hpb=ec577822f95a8bca0023c5c77cef1a4916822d4a;p=openssl.git diff --git a/crypto/threads/mttest.c b/crypto/threads/mttest.c index ff380908c1..100165948c 100644 --- a/crypto/threads/mttest.c +++ b/crypto/threads/mttest.c @@ -74,27 +74,29 @@ #include #include #endif +#ifdef PTHREADS +#include +#endif #include #include #include -#include "../e_os.h" +#include "../../e_os.h" #include #include #include +#include #ifdef NO_FP_API #define APPS_WIN16 -#include "../crypto/buffer/bss_file.c" +#include "../buffer/bss_file.c" #endif -#define TEST_SERVER_CERT "../apps/server.pem" -#define TEST_CLIENT_CERT "../apps/client.pem" +#define TEST_SERVER_CERT "../../apps/server.pem" +#define TEST_CLIENT_CERT "../../apps/client.pem" #define MAX_THREAD_NUMBER 100 -#ifndef NOPROTO -int MS_CALLBACK verify_callback(int ok, X509 *xs, X509 *xi, int depth, - int error,char *arg); +int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *xs); void thread_setup(void); void thread_cleanup(void); void do_threads(SSL_CTX *s_ctx,SSL_CTX *c_ctx); @@ -108,23 +110,6 @@ unsigned long irix_thread_id(void ); unsigned long solaris_thread_id(void ); unsigned long pthreads_thread_id(void ); -#else -int MS_CALLBACK verify_callback(); -void thread_setup(); -void thread_cleanup(); -void do_threads(); - -void irix_locking_callback(); -void solaris_locking_callback(); -void win32_locking_callback(); -void pthreads_locking_callback(); - -unsigned long irix_thread_id(); -unsigned long solaris_thread_id(); -unsigned long pthreads_thread_id(); - -#endif - BIO *bio_err=NULL; BIO *bio_stdout=NULL; @@ -139,12 +124,9 @@ int number_of_loops=10; int reconnect=0; int cache_stats=0; -#ifndef NOPROTO -int doit(char *ctx[4]); -#else -int doit(); -#endif +static const char rnd_seed[] = "string to make the random number generator think it has entropy"; +int doit(char *ctx[4]); static void print_stats(FILE *fp, SSL_CTX *ctx) { fprintf(fp,"%4ld items in the session cache\n", @@ -193,6 +175,8 @@ int main(int argc, char *argv[]) char *ccert=TEST_CLIENT_CERT; SSL_METHOD *ssl_method=SSLv23_method(); + RAND_seed(rnd_seed, sizeof rnd_seed); + if (bio_err == NULL) bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); if (bio_stdout == NULL) @@ -267,7 +251,7 @@ bad: if (cipher == NULL) cipher=getenv("SSL_CIPHER"); SSL_load_error_strings(); - SSLeay_add_ssl_algorithms(); + OpenSSL_add_ssl_algorithms(); c_ctx=SSL_CTX_new(ssl_method); s_ctx=SSL_CTX_new(ssl_method); @@ -282,8 +266,15 @@ bad: SSL_CTX_set_session_cache_mode(c_ctx, SSL_SESS_CACHE_NO_AUTO_CLEAR|SSL_SESS_CACHE_SERVER); - SSL_CTX_use_certificate_file(s_ctx,scert,SSL_FILETYPE_PEM); - SSL_CTX_use_RSAPrivateKey_file(s_ctx,scert,SSL_FILETYPE_PEM); + if (!SSL_CTX_use_certificate_file(s_ctx,scert,SSL_FILETYPE_PEM)) + { + ERR_print_errors(bio_err); + } + else if (!SSL_CTX_use_RSAPrivateKey_file(s_ctx,scert,SSL_FILETYPE_PEM)) + { + ERR_print_errors(bio_err); + goto end; + } if (client_auth) { @@ -512,6 +503,7 @@ int doit(char *ctx[4]) else { fprintf(stderr,"ERROR in CLIENT\n"); + ERR_print_errors_fp(stderr); return(1); } } @@ -543,6 +535,7 @@ int doit(char *ctx[4]) else { fprintf(stderr,"ERROR in CLIENT\n"); + ERR_print_errors_fp(stderr); return(1); } } @@ -675,18 +668,23 @@ err: return(0); } -int MS_CALLBACK verify_callback(int ok, X509 *xs, X509 *xi, int depth, - int error, char *arg) +int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx) { - char buf[256]; + char *s, buf[256]; if (verbose) { - X509_NAME_oneline(X509_get_subject_name(xs),buf,256); - if (ok) - fprintf(stderr,"depth=%d %s\n",depth,buf); - else - fprintf(stderr,"depth=%d error=%d %s\n",depth,error,buf); + s=X509_NAME_oneline(X509_get_subject_name(ctx->current_cert), + buf,256); + if (s != NULL) + { + if (ok) + fprintf(stderr,"depth=%d %s\n", + ctx->error_depth,buf); + else + fprintf(stderr,"depth=%d error=%d %s\n", + ctx->error_depth,ctx->error,buf); + } } return(ok); } @@ -695,13 +693,14 @@ int MS_CALLBACK verify_callback(int ok, X509 *xs, X509 *xi, int depth, #ifdef WIN32 -static HANDLE lock_cs[CRYPTO_NUM_LOCKS]; +static HANDLE *lock_cs; void thread_setup(void) { int i; - for (i=0; ireferences,c_ctx->references); + s_ctx->references,c_ctx->references); } unsigned long pthreads_thread_id(void)