2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
65 #include "openssl/e_os.h"
67 #include <openssl/bio.h>
68 #include <openssl/crypto.h>
69 #include <openssl/x509.h>
70 #include <openssl/ssl.h>
71 #include <openssl/err.h>
73 #include "../crypto/bio/bss_file.c"
76 #if defined(NO_RSA) && !defined(NO_SSL2)
81 # define TEST_SERVER_CERT "SYS$DISK:[-.APPS]SERVER.PEM"
82 # define TEST_CLIENT_CERT "SYS$DISK:[-.APPS]CLIENT.PEM"
84 # define TEST_SERVER_CERT "../apps/server.pem"
85 # define TEST_CLIENT_CERT "../apps/client.pem"
88 int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx);
90 static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export,int keylength);
93 static DH *get_dh512(void);
98 static char *cipher=NULL;
109 int doit_biopair(SSL *s_ssl,SSL *c_ssl,long bytes);
110 int doit(SSL *s_ssl,SSL *c_ssl,long bytes);
111 static void sv_usage(void)
113 fprintf(stderr,"usage: ssltest [args ...]\n");
114 fprintf(stderr,"\n");
115 fprintf(stderr," -server_auth - check server certificate\n");
116 fprintf(stderr," -client_auth - do client authentication\n");
117 fprintf(stderr," -v - more output\n");
118 fprintf(stderr," -d - debug output\n");
119 fprintf(stderr," -reuse - use session-id reuse\n");
120 fprintf(stderr," -num <val> - number of connections to perform\n");
121 fprintf(stderr," -bytes <val> - number of bytes to swap between client/server\n");
123 fprintf(stderr," -ssl2 - use SSLv2\n");
126 fprintf(stderr," -ssl3 - use SSLv3\n");
129 fprintf(stderr," -tls1 - use TLSv1\n");
131 fprintf(stderr," -CApath arg - PEM format directory of CA's\n");
132 fprintf(stderr," -CAfile arg - PEM format file of CA's\n");
133 fprintf(stderr," -cert arg - Certificate file\n");
134 fprintf(stderr," -s_cert arg - Just the server certificate file\n");
135 fprintf(stderr," -c_cert arg - Just the client certificate file\n");
136 fprintf(stderr," -cipher arg - The cipher list\n");
137 fprintf(stderr," -bio_pair - Use BIO pairs\n");
138 fprintf(stderr," -f - Test even cases that can't work\n");
141 int main(int argc, char *argv[])
143 char *CApath=NULL,*CAfile=NULL;
147 int tls1=0,ssl2=0,ssl3=0,ret=1;
150 char *server_cert=TEST_SERVER_CERT;
151 char *client_cert=TEST_CLIENT_CERT;
154 SSL_METHOD *meth=NULL;
156 int number=1,reuse=0;
163 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
164 bio_stdout=BIO_new_fp(stdout,BIO_NOCLOSE);
166 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
173 if (strcmp(*argv,"-server_auth") == 0)
175 else if (strcmp(*argv,"-client_auth") == 0)
177 else if (strcmp(*argv,"-v") == 0)
179 else if (strcmp(*argv,"-d") == 0)
181 else if (strcmp(*argv,"-reuse") == 0)
183 else if (strcmp(*argv,"-ssl2") == 0)
185 else if (strcmp(*argv,"-tls1") == 0)
187 else if (strcmp(*argv,"-ssl3") == 0)
189 else if (strncmp(*argv,"-num",4) == 0)
191 if (--argc < 1) goto bad;
192 number= atoi(*(++argv));
193 if (number == 0) number=1;
195 else if (strcmp(*argv,"-bytes") == 0)
197 if (--argc < 1) goto bad;
198 bytes= atol(*(++argv));
199 if (bytes == 0L) bytes=1L;
201 if (argv[0][i-1] == 'k') bytes*=1024L;
202 if (argv[0][i-1] == 'm') bytes*=1024L*1024L;
204 else if (strcmp(*argv,"-cert") == 0)
206 if (--argc < 1) goto bad;
207 server_cert= *(++argv);
209 else if (strcmp(*argv,"-s_cert") == 0)
211 if (--argc < 1) goto bad;
212 server_cert= *(++argv);
214 else if (strcmp(*argv,"-c_cert") == 0)
216 if (--argc < 1) goto bad;
217 client_cert= *(++argv);
219 else if (strcmp(*argv,"-cipher") == 0)
221 if (--argc < 1) goto bad;
224 else if (strcmp(*argv,"-CApath") == 0)
226 if (--argc < 1) goto bad;
229 else if (strcmp(*argv,"-CAfile") == 0)
231 if (--argc < 1) goto bad;
234 else if (strcmp(*argv,"-bio_pair") == 0)
238 else if (strcmp(*argv,"-f") == 0)
244 fprintf(stderr,"unknown option %s\n",*argv);
258 if (!ssl2 && !ssl3 && !tls1 && number > 1 && !reuse && !force)
260 fprintf(stderr, "This case cannot work. Use -f switch to perform "
262 "(and -d to see what happens, "
263 "and -bio_pair to really make it happen :-)\n"
264 "or add one of -ssl2, -ssl3, -tls1, -reuse to "
265 "avoid protocol mismatch.\n");
269 /* if (cipher == NULL) cipher=getenv("SSL_CIPHER"); */
272 SSL_load_error_strings();
274 #if !defined(NO_SSL2) && !defined(NO_SSL3)
284 meth=SSLv23_method();
293 c_ctx=SSL_CTX_new(meth);
294 s_ctx=SSL_CTX_new(meth);
295 if ((c_ctx == NULL) || (s_ctx == NULL))
297 ERR_print_errors(bio_err);
303 SSL_CTX_set_cipher_list(c_ctx,cipher);
304 SSL_CTX_set_cipher_list(s_ctx,cipher);
309 SSL_CTX_set_tmp_dh(s_ctx,dh);
314 SSL_CTX_set_tmp_rsa_callback(s_ctx,tmp_rsa_cb);
317 if (!SSL_CTX_use_certificate_file(s_ctx,server_cert,SSL_FILETYPE_PEM))
319 ERR_print_errors(bio_err);
321 else if (!SSL_CTX_use_PrivateKey_file(s_ctx,server_cert,
324 ERR_print_errors(bio_err);
330 SSL_CTX_use_certificate_file(c_ctx,client_cert,
332 SSL_CTX_use_PrivateKey_file(c_ctx,client_cert,
336 if ( (!SSL_CTX_load_verify_locations(s_ctx,CAfile,CApath)) ||
337 (!SSL_CTX_set_default_verify_paths(s_ctx)) ||
338 (!SSL_CTX_load_verify_locations(c_ctx,CAfile,CApath)) ||
339 (!SSL_CTX_set_default_verify_paths(c_ctx)))
341 /* fprintf(stderr,"SSL_load_verify_locations\n"); */
342 ERR_print_errors(bio_err);
348 fprintf(stderr,"client authentication\n");
349 SSL_CTX_set_verify(s_ctx,
350 SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
355 fprintf(stderr,"server authentication\n");
356 SSL_CTX_set_verify(c_ctx,SSL_VERIFY_PEER,
360 c_ssl=SSL_new(c_ctx);
361 s_ssl=SSL_new(s_ctx);
363 for (i=0; i<number; i++)
365 if (!reuse) SSL_set_session(c_ssl,NULL);
367 ret=doit_biopair(s_ssl,c_ssl,bytes);
369 ret=doit(s_ssl,c_ssl,bytes);
374 ciph=SSL_get_current_cipher(c_ssl);
375 fprintf(stdout,"Protocol %s, cipher %s, %s\n",
376 SSL_get_version(c_ssl),
377 SSL_CIPHER_get_version(ciph),
378 SSL_CIPHER_get_name(ciph));
380 if ((number > 1) || (bytes > 1L))
381 printf("%d handshakes of %ld bytes done\n",number,bytes);
387 if (s_ctx != NULL) SSL_CTX_free(s_ctx);
388 if (c_ctx != NULL) SSL_CTX_free(c_ctx);
390 if (bio_stdout != NULL) BIO_free(bio_stdout);
395 CRYPTO_mem_leaks(bio_err);
399 int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count)
401 long cw_num = count, cr_num = count, sw_num = count, sr_num = count;
402 BIO *s_ssl_bio = NULL, *c_ssl_bio = NULL;
403 BIO *server = NULL, *server_io = NULL, *client = NULL, *client_io = NULL;
407 size_t bufsiz = 256; /* small buffer for testing */
409 if (!BIO_new_bio_pair(&server, bufsiz, &server_io, bufsiz))
411 if (!BIO_new_bio_pair(&client, bufsiz, &client_io, bufsiz))
414 s_ssl_bio = BIO_new(BIO_f_ssl());
418 c_ssl_bio = BIO_new(BIO_f_ssl());
422 SSL_set_connect_state(c_ssl);
423 SSL_set_bio(c_ssl, client, client);
424 (void)BIO_set_ssl(c_ssl_bio, c_ssl, BIO_NOCLOSE);
426 SSL_set_accept_state(s_ssl);
427 SSL_set_bio(s_ssl, server, server);
428 (void)BIO_set_ssl(s_ssl_bio, s_ssl, BIO_NOCLOSE);
432 /* c_ssl_bio: SSL filter BIO
434 * client: pseudo-I/O for SSL library
436 * client_io: client's SSL communication; usually to be
437 * relayed over some I/O facility, but in this
438 * test program, we're the server, too:
440 * server_io: server's SSL communication
442 * server: pseudo-I/O for SSL library
444 * s_ssl_bio: SSL filter BIO
446 * The client and the server each employ a "BIO pair":
447 * client + client_io, server + server_io.
448 * BIO pairs are symmetric. A BIO pair behaves similar
449 * to a non-blocking socketpair (but both endpoints must
450 * be handled by the same thread).
451 * [Here we could connect client and server to the ends
452 * of a single BIO pair, but then this code would be less
453 * suitable as an example for BIO pairs in general.]
455 * Useful functions for querying the state of BIO pair endpoints:
457 * BIO_ctrl_pending(bio) number of bytes we can read now
458 * BIO_ctrl_get_read_request(bio) number of bytes needed to fulfil
459 * other side's read attempt
460 * BIO_ctrl_get_write_gurantee(bio) number of bytes we can write now
462 * ..._read_request is never more than ..._write_guarantee;
463 * it depends on the application which one you should use.
466 /* We have non-blocking behaviour throughout this test program, but
467 * can be sure that there is *some* progress in each iteration; so
468 * we don't have to worry about ..._SHOULD_READ or ..._SHOULD_WRITE
469 * -- we just try everything in each iteration
475 MS_STATIC char cbuf[1024*8];
479 if (SSL_in_init(c_ssl))
480 printf("client waiting in SSL_connect - %s\n",
481 SSL_state_string_long(c_ssl));
485 /* Write to server. */
487 if (cw_num > (long)sizeof cbuf)
491 r = BIO_write(c_ssl_bio, cbuf, i);
494 if (!BIO_should_retry(c_ssl_bio))
496 fprintf(stderr,"ERROR in CLIENT\n");
499 /* BIO_should_retry(...) can just be ignored here.
500 * The library expects us to call BIO_write with
501 * the same arguments again, and that's what we will
502 * do in the next iteration. */
506 fprintf(stderr,"SSL CLIENT STARTUP FAILED\n");
512 printf("client wrote %d\n", r);
519 /* Read from server. */
521 r = BIO_read(c_ssl_bio, cbuf, sizeof(cbuf));
524 if (!BIO_should_retry(c_ssl_bio))
526 fprintf(stderr,"ERROR in CLIENT\n");
529 /* Again, "BIO_should_retry" can be ignored. */
533 fprintf(stderr,"SSL CLIENT STARTUP FAILED\n");
539 printf("client read %d\n", r);
548 MS_STATIC char sbuf[1024*8];
552 if (SSL_in_init(s_ssl))
553 printf("server waiting in SSL_accept - %s\n",
554 SSL_state_string_long(s_ssl));
558 /* Write to client. */
560 if (sw_num > (long)sizeof sbuf)
564 r = BIO_write(s_ssl_bio, sbuf, i);
567 if (!BIO_should_retry(s_ssl_bio))
569 fprintf(stderr,"ERROR in SERVER\n");
572 /* Ignore "BIO_should_retry". */
576 fprintf(stderr,"SSL SERVER STARTUP FAILED\n");
582 printf("server wrote %d\n", r);
589 /* Read from client. */
591 r = BIO_read(s_ssl_bio, sbuf, sizeof(sbuf));
594 if (!BIO_should_retry(s_ssl_bio))
596 fprintf(stderr,"ERROR in SERVER\n");
603 fprintf(stderr,"SSL SERVER STARTUP FAILED\n");
609 printf("server read %d\n", r);
616 /* "I/O" BETWEEN CLIENT AND SERVER. */
618 #define RELAYBUFSIZ 200
619 static char buf[RELAYBUFSIZ];
621 /* RELAYBUF is arbitrary. When writing data over some real
622 * network, use a buffer of the same size as in the BIO_pipe
623 * and make that size large (for reading from the network
624 * small buffers usually won't hurt).
625 * Here sizes differ for testing. */
630 static int prev_progress = 1;
633 /* client to server */
636 r1 = BIO_ctrl_pending(client_io);
637 r2 = BIO_ctrl_get_write_guarantee(server_io);
644 if (sizeof buf < num)
646 if (INT_MAX < num) /* yeah, right */
649 r = BIO_read(client_io, buf, (int)num);
650 if (r != (int)num) /* can't happen */
652 fprintf(stderr, "ERROR: BIO_read could not read "
653 "BIO_ctrl_pending() bytes");
656 r = BIO_write(server_io, buf, (int)num);
657 if (r != (int)num) /* can't happen */
659 fprintf(stderr, "ERROR: BIO_write could not write "
660 "BIO_ctrl_get_write_guarantee() bytes");
666 printf("C->S relaying: %d bytes\n", (int)num);
671 /* server to client */
674 r1 = BIO_ctrl_pending(server_io);
675 r2 = BIO_ctrl_get_write_guarantee(client_io);
682 if (sizeof buf < num)
687 r = BIO_read(server_io, buf, (int)num);
688 if (r != (int)num) /* can't happen */
690 fprintf(stderr, "ERROR: BIO_read could not read "
691 "BIO_ctrl_pending() bytes");
694 r = BIO_write(client_io, buf, (int)num);
695 if (r != (int)num) /* can't happen */
697 fprintf(stderr, "ERROR: BIO_write could not write "
698 "BIO_ctrl_get_write_guarantee() bytes");
704 printf("S->C relaying: %d bytes\n", (int)num);
709 if (!progress && !prev_progress)
710 if (cw_num > 0 || cr_num > 0 || sw_num > 0 || sr_num > 0)
712 fprintf(stderr, "ERROR: got stuck\n");
713 if (strcmp("SSLv2", SSL_get_version(c_ssl)) == 0)
715 fprintf(stderr, "This can happen for SSL2 because "
716 "CLIENT-FINISHED and SERVER-VERIFY are written \n"
718 if (strncmp("2SCF", SSL_state_string(c_ssl), 4) == 0
719 && strncmp("2SSV", SSL_state_string(s_ssl), 4) == 0)
721 fprintf(stderr, " ok.\n");
725 fprintf(stderr, " ERROR.\n");
728 prev_progress = progress;
731 while (cw_num > 0 || cr_num > 0 || sw_num > 0 || sr_num > 0);
733 ciph = SSL_get_current_cipher(c_ssl);
735 fprintf(stdout,"DONE via BIO pair, protocol %s, cipher %s, %s\n",
736 SSL_get_version(c_ssl),
737 SSL_CIPHER_get_version(ciph),
738 SSL_CIPHER_get_name(ciph));
743 ERR_print_errors(bio_err);
767 int doit(SSL *s_ssl, SSL *c_ssl, long count)
769 MS_STATIC char cbuf[1024*8],sbuf[1024*8];
770 long cw_num=count,cr_num=count;
771 long sw_num=count,sr_num=count;
782 int do_server=0,do_client=0;
785 c_to_s=BIO_new(BIO_s_mem());
786 s_to_c=BIO_new(BIO_s_mem());
787 if ((s_to_c == NULL) || (c_to_s == NULL))
789 ERR_print_errors(bio_err);
793 c_bio=BIO_new(BIO_f_ssl());
794 s_bio=BIO_new(BIO_f_ssl());
795 if ((c_bio == NULL) || (s_bio == NULL))
797 ERR_print_errors(bio_err);
801 SSL_set_connect_state(c_ssl);
802 SSL_set_bio(c_ssl,s_to_c,c_to_s);
803 BIO_set_ssl(c_bio,c_ssl,BIO_NOCLOSE);
805 SSL_set_accept_state(s_ssl);
806 SSL_set_bio(s_ssl,c_to_s,s_to_c);
807 BIO_set_ssl(s_bio,s_ssl,BIO_NOCLOSE);
815 /* We can always do writes */
821 i=(int)BIO_pending(s_bio);
822 if ((i && s_r) || s_w) do_server=1;
824 i=(int)BIO_pending(c_bio);
825 if ((i && c_r) || c_w) do_client=1;
827 if (do_server && debug)
829 if (SSL_in_init(s_ssl))
830 printf("server waiting in SSL_accept - %s\n",
831 SSL_state_string_long(s_ssl));
833 printf("server:SSL_write()\n");
835 printf("server:SSL_read()\n"); */
838 if (do_client && debug)
840 if (SSL_in_init(c_ssl))
841 printf("client waiting in SSL_connect - %s\n",
842 SSL_state_string_long(c_ssl));
844 printf("client:SSL_write()\n");
846 printf("client:SSL_read()\n"); */
849 if (!do_client && !do_server)
851 fprintf(stdout,"ERROR IN STARTUP\n");
852 ERR_print_errors(bio_err);
855 if (do_client && !(done & C_DONE))
859 j=(cw_num > (long)sizeof(cbuf))
860 ?sizeof(cbuf):(int)cw_num;
861 i=BIO_write(c_bio,cbuf,j);
866 if (BIO_should_retry(c_bio))
868 if (BIO_should_read(c_bio))
870 if (BIO_should_write(c_bio))
875 fprintf(stderr,"ERROR in CLIENT\n");
876 ERR_print_errors(bio_err);
882 fprintf(stderr,"SSL CLIENT STARTUP FAILED\n");
888 printf("client wrote %d\n",i);
897 i=BIO_read(c_bio,cbuf,sizeof(cbuf));
902 if (BIO_should_retry(c_bio))
904 if (BIO_should_read(c_bio))
906 if (BIO_should_write(c_bio))
911 fprintf(stderr,"ERROR in CLIENT\n");
912 ERR_print_errors(bio_err);
918 fprintf(stderr,"SSL CLIENT STARTUP FAILED\n");
924 printf("client read %d\n",i);
941 if (do_server && !(done & S_DONE))
945 i=BIO_read(s_bio,sbuf,sizeof(cbuf));
950 if (BIO_should_retry(s_bio))
952 if (BIO_should_read(s_bio))
954 if (BIO_should_write(s_bio))
959 fprintf(stderr,"ERROR in SERVER\n");
960 ERR_print_errors(bio_err);
966 ERR_print_errors(bio_err);
967 fprintf(stderr,"SSL SERVER STARTUP FAILED in SSL_read\n");
973 printf("server read %d\n",i);
990 j=(sw_num > (long)sizeof(sbuf))?
991 sizeof(sbuf):(int)sw_num;
992 i=BIO_write(s_bio,sbuf,j);
997 if (BIO_should_retry(s_bio))
999 if (BIO_should_read(s_bio))
1001 if (BIO_should_write(s_bio))
1006 fprintf(stderr,"ERROR in SERVER\n");
1007 ERR_print_errors(bio_err);
1013 ERR_print_errors(bio_err);
1014 fprintf(stderr,"SSL SERVER STARTUP FAILED in SSL_write\n");
1020 printf("server wrote %d\n",i);
1030 if ((done & S_DONE) && (done & C_DONE)) break;
1033 ciph=SSL_get_current_cipher(c_ssl);
1035 fprintf(stdout,"DONE, protocol %s, cipher %s, %s\n",
1036 SSL_get_version(c_ssl),
1037 SSL_CIPHER_get_version(ciph),
1038 SSL_CIPHER_get_name(ciph));
1041 /* We have to set the BIO's to NULL otherwise they will be
1042 * Free()ed twice. Once when th s_ssl is SSL_free()ed and
1043 * again when c_ssl is SSL_free()ed.
1044 * This is a hack required because s_ssl and c_ssl are sharing the same
1045 * BIO structure and SSL_set_bio() and SSL_free() automatically
1046 * BIO_free non NULL entries.
1047 * You should not normally do this or be required to do this */
1059 if (c_to_s != NULL) BIO_free(c_to_s);
1060 if (s_to_c != NULL) BIO_free(s_to_c);
1061 if (c_bio != NULL) BIO_free_all(c_bio);
1062 if (s_bio != NULL) BIO_free_all(s_bio);
1066 int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx)
1070 s=X509_NAME_oneline(X509_get_subject_name(ctx->current_cert),buf,256);
1074 fprintf(stderr,"depth=%d %s\n",ctx->error_depth,buf);
1076 fprintf(stderr,"depth=%d error=%d %s\n",
1077 ctx->error_depth,ctx->error,buf);
1084 case X509_V_ERR_CERT_NOT_YET_VALID:
1085 case X509_V_ERR_CERT_HAS_EXPIRED:
1086 case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT:
1095 static unsigned char dh512_p[]={
1096 0xDA,0x58,0x3C,0x16,0xD9,0x85,0x22,0x89,0xD0,0xE4,0xAF,0x75,
1097 0x6F,0x4C,0xCA,0x92,0xDD,0x4B,0xE5,0x33,0xB8,0x04,0xFB,0x0F,
1098 0xED,0x94,0xEF,0x9C,0x8A,0x44,0x03,0xED,0x57,0x46,0x50,0xD3,
1099 0x69,0x99,0xDB,0x29,0xD7,0x76,0x27,0x6B,0xA2,0xD3,0xD4,0x12,
1100 0xE2,0x18,0xF4,0xDD,0x1E,0x08,0x4C,0xF6,0xD8,0x00,0x3E,0x7C,
1101 0x47,0x74,0xE8,0x33,
1103 static unsigned char dh512_g[]={
1107 static DH *get_dh512(void)
1111 if ((dh=DH_new()) == NULL) return(NULL);
1112 dh->p=BN_bin2bn(dh512_p,sizeof(dh512_p),NULL);
1113 dh->g=BN_bin2bn(dh512_g,sizeof(dh512_g),NULL);
1114 if ((dh->p == NULL) || (dh->g == NULL))
1121 static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength)
1123 static RSA *rsa_tmp=NULL;
1125 if (rsa_tmp == NULL)
1127 BIO_printf(bio_err,"Generating temp (%d bit) RSA key...",keylength);
1128 (void)BIO_flush(bio_err);
1129 rsa_tmp=RSA_generate_key(keylength,RSA_F4,NULL,NULL);
1130 BIO_printf(bio_err,"\n");
1131 (void)BIO_flush(bio_err);