1 /* $OpenBSD: s_client.c,v 1.36 2018/02/11 20:03:10 jmc Exp $ */
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.]
58 /* ====================================================================
59 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions
65 * 1. Redistributions of source code must retain the above copyright
66 * notice, this list of conditions and the following disclaimer.
68 * 2. Redistributions in binary form must reproduce the above copyright
69 * notice, this list of conditions and the following disclaimer in
70 * the documentation and/or other materials provided with the
73 * 3. All advertising materials mentioning features or use of this
74 * software must display the following acknowledgment:
75 * "This product includes software developed by the OpenSSL Project
76 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
78 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
79 * endorse or promote products derived from this software without
80 * prior written permission. For written permission, please contact
81 * openssl-core@openssl.org.
83 * 5. Products derived from this software may not be called "OpenSSL"
84 * nor may "OpenSSL" appear in their names without prior written
85 * permission of the OpenSSL Project.
87 * 6. Redistributions of any form whatsoever must retain the following
89 * "This product includes software developed by the OpenSSL Project
90 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
92 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
93 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
94 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
96 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
97 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
98 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
101 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
102 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
103 * OF THE POSSIBILITY OF SUCH DAMAGE.
104 * ====================================================================
106 * This product includes cryptographic software written by Eric Young
107 * (eay@cryptsoft.com). This product includes software written by Tim
108 * Hudson (tjh@cryptsoft.com).
111 /* ====================================================================
112 * Copyright 2005 Nokia. All rights reserved.
114 * The portions of the attached software ("Contribution") is developed by
115 * Nokia Corporation and is licensed pursuant to the OpenSSL open source
118 * The Contribution, originally written by Mika Kousa and Pasi Eronen of
119 * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites
120 * support (see RFC 4279) to OpenSSL.
122 * No patent licenses or other rights except those expressly stated in
123 * the OpenSSL open source license shall be deemed granted or received
124 * expressly, by implication, estoppel, or otherwise.
126 * No assurances are provided by Nokia that the Contribution does not
127 * infringe the patent or other intellectual property rights of any third
128 * party or that the license provides you with all the necessary rights
129 * to make use of the Contribution.
131 * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN
132 * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA
133 * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY
134 * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
138 #include <sys/types.h>
139 #include <sys/socket.h>
141 #include <netinet/in.h>
155 #include <openssl/bn.h>
156 #include <openssl/err.h>
157 #include <openssl/ocsp.h>
158 #include <openssl/pem.h>
159 #include <openssl/ssl.h>
160 #include <openssl/x509.h>
163 #include "timeouts.h"
165 /*#define SSL_HOST_NAME "www.netscape.com" */
166 /*#define SSL_HOST_NAME "193.118.187.102" */
167 #define SSL_HOST_NAME "localhost"
169 /*#define TEST_CERT "client.pem" *//* no default cert. */
171 #define BUFSIZZ 1024*8
173 static int c_nbio
= 0;
174 static int c_Pause
= 0;
175 static int c_debug
= 0;
176 static int c_tlsextdebug
= 0;
177 static int c_status_req
= 0;
178 static int c_msg
= 0;
179 static int c_showcerts
= 0;
181 static char *keymatexportlabel
= NULL
;
182 static int keymatexportlen
= 20;
184 static void sc_usage(void);
185 static void print_stuff(BIO
* berr
, SSL
* con
, int full
);
186 static int ocsp_resp_cb(SSL
* s
, void *arg
);
187 static BIO
*bio_c_out
= NULL
;
188 static int c_quiet
= 0;
189 static int c_ign_eof
= 0;
195 BIO_printf(bio_err
, "usage: s_client args\n");
196 BIO_printf(bio_err
, "\n");
197 BIO_printf(bio_err
, " -4 - Force IPv4\n");
198 BIO_printf(bio_err
, " -6 - Force IPv6\n");
199 BIO_printf(bio_err
, " -host host - use -connect instead\n");
200 BIO_printf(bio_err
, " -port port - use -connect instead\n");
201 BIO_printf(bio_err
, " -connect host:port - who to connect to (default is %s:%s)\n", SSL_HOST_NAME
, PORT_STR
);
202 BIO_printf(bio_err
, " -proxy host:port - connect to http proxy\n");
204 BIO_printf(bio_err
, " -verify arg - turn on peer certificate verification\n");
205 BIO_printf(bio_err
, " -cert arg - certificate file to use, PEM format assumed\n");
206 BIO_printf(bio_err
, " -certform arg - certificate format (PEM or DER) PEM default\n");
207 BIO_printf(bio_err
, " -key arg - Private key file to use, in cert file if\n");
208 BIO_printf(bio_err
, " not specified but cert file is.\n");
209 BIO_printf(bio_err
, " -keyform arg - key format (PEM or DER) PEM default\n");
210 BIO_printf(bio_err
, " -pass arg - private key file pass phrase source\n");
211 BIO_printf(bio_err
, " -CApath arg - PEM format directory of CA's\n");
212 BIO_printf(bio_err
, " -CAfile arg - PEM format file of CA's\n");
213 BIO_printf(bio_err
, " -reconnect - Drop and re-make the connection with the same Session-ID\n");
214 BIO_printf(bio_err
, " -pause - sleep(1) after each read(2) and write(2) system call\n");
215 BIO_printf(bio_err
, " -showcerts - show all certificates in the chain\n");
216 BIO_printf(bio_err
, " -debug - extra output\n");
217 BIO_printf(bio_err
, " -msg - Show protocol messages\n");
218 BIO_printf(bio_err
, " -nbio_test - more ssl protocol testing\n");
219 BIO_printf(bio_err
, " -state - print the 'ssl' states\n");
220 BIO_printf(bio_err
, " -nbio - Run with non-blocking IO\n");
221 BIO_printf(bio_err
, " -crlf - convert LF from terminal into CRLF\n");
222 BIO_printf(bio_err
, " -quiet - no s_client output\n");
223 BIO_printf(bio_err
, " -ign_eof - ignore input eof (default when -quiet)\n");
224 BIO_printf(bio_err
, " -no_ign_eof - don't ignore input eof\n");
225 BIO_printf(bio_err
, " -tls1_2 - just use TLSv1.2\n");
226 BIO_printf(bio_err
, " -tls1_1 - just use TLSv1.1\n");
227 BIO_printf(bio_err
, " -tls1 - just use TLSv1\n");
228 BIO_printf(bio_err
, " -dtls1 - just use DTLSv1\n");
229 BIO_printf(bio_err
, " -mtu - set the link layer MTU\n");
230 BIO_printf(bio_err
, " -no_tls1_2/-no_tls1_1/-no_tls1/-no_ssl3/-no_ssl2 - turn off that protocol\n");
231 BIO_printf(bio_err
, " -bugs - Switch on all SSL implementation bug workarounds\n");
232 BIO_printf(bio_err
, " -cipher - preferred cipher to use, use the 'openssl ciphers'\n");
233 BIO_printf(bio_err
, " command to see what is available\n");
234 BIO_printf(bio_err
, " -starttls prot - use the STARTTLS command before starting TLS\n");
235 BIO_printf(bio_err
, " for those protocols that support it, where\n");
236 BIO_printf(bio_err
, " 'prot' defines which one to assume. Currently,\n");
237 BIO_printf(bio_err
, " only \"smtp\", \"lmtp\", \"pop3\", \"imap\", \"ftp\" and \"xmpp\"\n");
238 BIO_printf(bio_err
, " are supported.\n");
239 BIO_printf(bio_err
, " -xmpphost host - connect to this virtual host on the xmpp server\n");
240 BIO_printf(bio_err
, " -sess_out arg - file to write SSL session to\n");
241 BIO_printf(bio_err
, " -sess_in arg - file to read SSL session from\n");
242 BIO_printf(bio_err
, " -servername host - Set TLS extension servername in ClientHello\n");
243 BIO_printf(bio_err
, " -tlsextdebug - hex dump of all TLS extensions received\n");
244 BIO_printf(bio_err
, " -status - request certificate status from server\n");
245 BIO_printf(bio_err
, " -no_ticket - disable use of RFC4507bis session tickets\n");
246 BIO_printf(bio_err
, " -alpn arg - enable ALPN extension, considering named protocols supported (comma-separated list)\n");
247 BIO_printf(bio_err
, " -groups arg - specify EC curve groups (colon-separated list)\n");
248 #ifndef OPENSSL_NO_SRTP
249 BIO_printf(bio_err
, " -use_srtp profiles - Offer SRTP key management with a colon-separated profile list\n");
251 BIO_printf(bio_err
, " -keymatexport label - Export keying material using label\n");
252 BIO_printf(bio_err
, " -keymatexportlen len - Export len bytes of keying material (default 20)\n");
256 /* This is a context that we pass to callbacks */
257 typedef struct tlsextctx_st
{
264 ssl_servername_cb(SSL
* s
, int *ad
, void *arg
)
266 tlsextctx
*p
= (tlsextctx
*) arg
;
267 const char *hn
= SSL_get_servername(s
, TLSEXT_NAMETYPE_host_name
);
268 if (SSL_get_servername_type(s
) != -1)
269 p
->ack
= !SSL_session_reused(s
) && hn
!= NULL
;
271 BIO_printf(bio_err
, "Can't use SSL_get_servername\n");
273 return SSL_TLSEXT_ERR_OK
;
276 #ifndef OPENSSL_NO_SRTP
277 char *srtp_profiles
= NULL
;
291 s_client_main(int argc
, char **argv
)
293 unsigned int off
= 0, clr
= 0;
295 int s
, k
, state
= 0, af
= AF_UNSPEC
;
296 char *cbuf
= NULL
, *sbuf
= NULL
, *mbuf
= NULL
;
297 int cbuf_len
, cbuf_off
;
298 int sbuf_len
, sbuf_off
;
299 char *port
= PORT_STR
;
301 char *host
= SSL_HOST_NAME
;
302 char *xmpphost
= NULL
;
303 char *proxy
= NULL
, *connect
= NULL
;
304 char *cert_file
= NULL
, *key_file
= NULL
;
305 int cert_format
= FORMAT_PEM
, key_format
= FORMAT_PEM
;
306 char *passarg
= NULL
, *pass
= NULL
;
308 EVP_PKEY
*key
= NULL
;
309 char *CApath
= NULL
, *CAfile
= NULL
, *cipher
= NULL
;
310 int reconnect
= 0, badop
= 0, verify
= SSL_VERIFY_NONE
, bugs
= 0;
312 int write_tty
, read_tty
, write_ssl
, read_ssl
, tty_on
, ssl_pending
;
314 int ret
= 1, in_init
= 1, i
, nbio_test
= 0;
315 int starttls_proto
= PROTO_OFF
;
317 X509_VERIFY_PARAM
*vpm
= NULL
;
319 const SSL_METHOD
*meth
= NULL
;
320 int socket_type
= SOCK_STREAM
;
323 struct timeval timeout
;
324 const char *errstr
= NULL
;
325 char *servername
= NULL
;
326 tlsextctx tlsextcbp
= {NULL
, 0};
327 const char *alpn_in
= NULL
;
328 const char *groups_in
= NULL
;
329 char *sess_in
= NULL
;
330 char *sess_out
= NULL
;
331 struct sockaddr peer
;
332 int peerlen
= sizeof(peer
);
333 int enable_timeouts
= 0;
336 if (single_execution
) {
337 if (pledge("stdio cpath wpath rpath inet dns tty", NULL
) == -1) {
343 meth
= SSLv23_client_method();
352 if (((cbuf
= malloc(BUFSIZZ
)) == NULL
) ||
353 ((sbuf
= malloc(BUFSIZZ
)) == NULL
) ||
354 ((mbuf
= malloc(BUFSIZZ
+ 1)) == NULL
)) { /* NUL byte */
355 BIO_printf(bio_err
, "out of memory\n");
364 if (strcmp(*argv
, "-host") == 0) {
368 } else if (strcmp(*argv
, "-port") == 0) {
372 if (port
== NULL
|| *port
== '\0')
374 } else if (strcmp(*argv
, "-connect") == 0) {
378 } else if (strcmp(*argv
, "-proxy") == 0) {
382 } else if (strcmp(*argv
,"-xmpphost") == 0) {
386 } else if (strcmp(*argv
, "-verify") == 0) {
387 verify
= SSL_VERIFY_PEER
;
390 verify_depth
= strtonum(*(++argv
), 0, INT_MAX
, &errstr
);
393 BIO_printf(bio_err
, "verify depth is %d\n", verify_depth
);
394 } else if (strcmp(*argv
, "-cert") == 0) {
397 cert_file
= *(++argv
);
398 } else if (strcmp(*argv
, "-sess_out") == 0) {
401 sess_out
= *(++argv
);
402 } else if (strcmp(*argv
, "-sess_in") == 0) {
406 } else if (strcmp(*argv
, "-certform") == 0) {
409 cert_format
= str2fmt(*(++argv
));
410 } else if (args_verify(&argv
, &argc
, &badarg
, bio_err
, &vpm
)) {
414 } else if (strcmp(*argv
, "-verify_return_error") == 0)
415 verify_return_error
= 1;
416 else if (strcmp(*argv
, "-prexit") == 0)
418 else if (strcmp(*argv
, "-crlf") == 0)
420 else if (strcmp(*argv
, "-quiet") == 0) {
423 } else if (strcmp(*argv
, "-ign_eof") == 0)
425 else if (strcmp(*argv
, "-no_ign_eof") == 0)
427 else if (strcmp(*argv
, "-pause") == 0)
429 else if (strcmp(*argv
, "-debug") == 0)
431 else if (strcmp(*argv
, "-tlsextdebug") == 0)
433 else if (strcmp(*argv
, "-status") == 0)
435 else if (strcmp(*argv
, "-msg") == 0)
437 else if (strcmp(*argv
, "-showcerts") == 0)
439 else if (strcmp(*argv
, "-nbio_test") == 0)
441 else if (strcmp(*argv
, "-state") == 0)
443 else if (strcmp(*argv
, "-tls1_2") == 0)
444 meth
= TLSv1_2_client_method();
445 else if (strcmp(*argv
, "-tls1_1") == 0)
446 meth
= TLSv1_1_client_method();
447 else if (strcmp(*argv
, "-tls1") == 0)
448 meth
= TLSv1_client_method();
449 #ifndef OPENSSL_NO_DTLS1
450 else if (strcmp(*argv
, "-dtls1") == 0) {
451 meth
= DTLSv1_client_method();
452 socket_type
= SOCK_DGRAM
;
453 } else if (strcmp(*argv
, "-timeout") == 0)
455 else if (strcmp(*argv
, "-mtu") == 0) {
458 socket_mtu
= strtonum(*(++argv
), 0, LONG_MAX
, &errstr
);
463 else if (strcmp(*argv
, "-bugs") == 0)
465 else if (strcmp(*argv
, "-keyform") == 0) {
468 key_format
= str2fmt(*(++argv
));
469 } else if (strcmp(*argv
, "-pass") == 0) {
473 } else if (strcmp(*argv
, "-key") == 0) {
476 key_file
= *(++argv
);
477 } else if (strcmp(*argv
, "-reconnect") == 0) {
479 } else if (strcmp(*argv
, "-CApath") == 0) {
483 } else if (strcmp(*argv
, "-CAfile") == 0) {
487 } else if (strcmp(*argv
, "-no_tls1_2") == 0)
488 off
|= SSL_OP_NO_TLSv1_2
;
489 else if (strcmp(*argv
, "-no_tls1_1") == 0)
490 off
|= SSL_OP_NO_TLSv1_1
;
491 else if (strcmp(*argv
, "-no_tls1") == 0)
492 off
|= SSL_OP_NO_TLSv1
;
493 else if (strcmp(*argv
, "-no_ssl3") == 0)
494 off
|= SSL_OP_NO_SSLv3
;
495 else if (strcmp(*argv
, "-no_ssl2") == 0)
496 off
|= SSL_OP_NO_SSLv2
;
497 else if (strcmp(*argv
, "-no_comp") == 0) {
498 off
|= SSL_OP_NO_COMPRESSION
;
499 } else if (strcmp(*argv
, "-no_ticket") == 0) {
500 off
|= SSL_OP_NO_TICKET
;
501 } else if (strcmp(*argv
, "-nextprotoneg") == 0) {
506 } else if (strcmp(*argv
, "-alpn") == 0) {
510 } else if (strcmp(*argv
, "-groups") == 0) {
513 groups_in
= *(++argv
);
514 } else if (strcmp(*argv
, "-serverpref") == 0)
515 off
|= SSL_OP_CIPHER_SERVER_PREFERENCE
;
516 else if (strcmp(*argv
, "-legacy_renegotiation") == 0)
518 else if (strcmp(*argv
, "-legacy_server_connect") == 0) {
519 off
|= SSL_OP_LEGACY_SERVER_CONNECT
;
520 } else if (strcmp(*argv
, "-no_legacy_server_connect") == 0) {
521 clr
|= SSL_OP_LEGACY_SERVER_CONNECT
;
522 } else if (strcmp(*argv
, "-cipher") == 0) {
527 else if (strcmp(*argv
, "-nbio") == 0) {
530 else if (strcmp(*argv
, "-starttls") == 0) {
534 if (strcmp(*argv
, "smtp") == 0)
535 starttls_proto
= PROTO_SMTP
;
536 else if (strcmp(*argv
, "lmtp") == 0)
537 starttls_proto
= PROTO_LMTP
;
538 else if (strcmp(*argv
, "pop3") == 0)
539 starttls_proto
= PROTO_POP3
;
540 else if (strcmp(*argv
, "imap") == 0)
541 starttls_proto
= PROTO_IMAP
;
542 else if (strcmp(*argv
, "ftp") == 0)
543 starttls_proto
= PROTO_FTP
;
544 else if (strcmp(*argv
, "xmpp") == 0)
545 starttls_proto
= PROTO_XMPP
;
549 else if (strcmp(*argv
, "-4") == 0) {
551 } else if (strcmp(*argv
, "-6") == 0) {
554 else if (strcmp(*argv
, "-servername") == 0) {
557 servername
= *(++argv
);
558 /* meth=TLSv1_client_method(); */
560 #ifndef OPENSSL_NO_SRTP
561 else if (strcmp(*argv
, "-use_srtp") == 0) {
564 srtp_profiles
= *(++argv
);
567 else if (strcmp(*argv
, "-keymatexport") == 0) {
570 keymatexportlabel
= *(++argv
);
571 } else if (strcmp(*argv
, "-keymatexportlen") == 0) {
574 keymatexportlen
= strtonum(*(++argv
), 1, INT_MAX
, &errstr
);
578 BIO_printf(bio_err
, "unknown option %s\n", *argv
);
586 if (!extract_host_port(proxy
, &host
, NULL
, &port
))
589 connect
= SSL_HOST_NAME
;
590 } else if (connect
!= NULL
) {
591 if (!extract_host_port(connect
, &host
, NULL
, &port
))
597 BIO_printf(bio_err
, "invalid argument %s: %s\n",
604 if (!app_passwd(bio_err
, passarg
, NULL
, &pass
, NULL
)) {
605 BIO_printf(bio_err
, "Error getting password\n");
608 if (key_file
== NULL
)
609 key_file
= cert_file
;
614 key
= load_key(bio_err
, key_file
, key_format
, 0, pass
,
615 "client certificate private key file");
617 ERR_print_errors(bio_err
);
622 cert
= load_cert(bio_err
, cert_file
, cert_format
,
623 NULL
, "client certificate file");
626 ERR_print_errors(bio_err
);
630 if (bio_c_out
== NULL
) {
631 if (c_quiet
&& !c_debug
&& !c_msg
) {
632 bio_c_out
= BIO_new(BIO_s_null());
634 if (bio_c_out
== NULL
)
635 bio_c_out
= BIO_new_fp(stdout
, BIO_NOCLOSE
);
639 ctx
= SSL_CTX_new(meth
);
641 ERR_print_errors(bio_err
);
645 SSL_CTX_set1_param(ctx
, vpm
);
647 #ifndef OPENSSL_NO_SRTP
648 if (srtp_profiles
!= NULL
)
649 SSL_CTX_set_tlsext_use_srtp(ctx
, srtp_profiles
);
652 SSL_CTX_set_options(ctx
, SSL_OP_ALL
| off
);
654 SSL_CTX_set_options(ctx
, off
);
657 SSL_CTX_clear_options(ctx
, clr
);
659 * DTLS: partial reads end up discarding unread UDP bytes :-( Setting
660 * read ahead solves this problem.
662 if (socket_type
== SOCK_DGRAM
)
663 SSL_CTX_set_read_ahead(ctx
, 1);
666 unsigned short alpn_len
;
667 unsigned char *alpn
= next_protos_parse(&alpn_len
, alpn_in
);
670 BIO_printf(bio_err
, "Error parsing -alpn argument\n");
673 SSL_CTX_set_alpn_protos(ctx
, alpn
, alpn_len
);
676 if (groups_in
!= NULL
) {
677 if (SSL_CTX_set1_groups_list(ctx
, groups_in
) != 1) {
678 BIO_printf(bio_err
, "Failed to set groups '%s'\n",
685 SSL_CTX_set_info_callback(ctx
, apps_ssl_info_callback
);
687 if (!SSL_CTX_set_cipher_list(ctx
, cipher
)) {
688 BIO_printf(bio_err
, "error setting cipher list\n");
689 ERR_print_errors(bio_err
);
693 SSL_CTX_set_verify(ctx
, verify
, verify_callback
);
694 if (!set_cert_key_stuff(ctx
, cert
, key
))
697 if ((CAfile
|| CApath
)
698 && !SSL_CTX_load_verify_locations(ctx
, CAfile
, CApath
))
699 ERR_print_errors(bio_err
);
701 if (!SSL_CTX_set_default_verify_paths(ctx
))
702 ERR_print_errors(bio_err
);
704 if (servername
!= NULL
) {
705 tlsextcbp
.biodebug
= bio_err
;
706 SSL_CTX_set_tlsext_servername_callback(ctx
, ssl_servername_cb
);
707 SSL_CTX_set_tlsext_servername_arg(ctx
, &tlsextcbp
);
713 BIO
*stmp
= BIO_new_file(sess_in
, "r");
715 BIO_printf(bio_err
, "Can't open session file %s\n",
717 ERR_print_errors(bio_err
);
720 sess
= PEM_read_bio_SSL_SESSION(stmp
, NULL
, 0, NULL
);
723 BIO_printf(bio_err
, "Can't open session file %s\n",
725 ERR_print_errors(bio_err
);
728 SSL_set_session(con
, sess
);
729 SSL_SESSION_free(sess
);
731 if (servername
!= NULL
) {
732 if (!SSL_set_tlsext_host_name(con
, servername
)) {
733 BIO_printf(bio_err
, "Unable to set TLS servername extension.\n");
734 ERR_print_errors(bio_err
);
738 /* SSL_set_cipher_list(con,"RC4-MD5"); */
742 if (init_client(&s
, host
, port
, socket_type
, af
) == 0) {
743 BIO_printf(bio_err
, "connect:errno=%d\n", errno
);
746 BIO_printf(bio_c_out
, "CONNECTED(%08X)\n", s
);
750 BIO_printf(bio_c_out
, "turning on non blocking io\n");
751 if (!BIO_socket_nbio(s
, 1)) {
752 ERR_print_errors(bio_err
);
757 SSL_set_debug(con
, 1);
759 if (SSL_version(con
) == DTLS1_VERSION
) {
761 sbio
= BIO_new_dgram(s
, BIO_NOCLOSE
);
762 if (getsockname(s
, &peer
, (void *) &peerlen
) < 0) {
763 BIO_printf(bio_err
, "getsockname:errno=%d\n",
765 shutdown(s
, SHUT_RD
);
769 (void) BIO_ctrl_set_connected(sbio
, 1, &peer
);
771 if (enable_timeouts
) {
773 timeout
.tv_usec
= DGRAM_RCV_TIMEOUT
;
774 BIO_ctrl(sbio
, BIO_CTRL_DGRAM_SET_RECV_TIMEOUT
, 0, &timeout
);
777 timeout
.tv_usec
= DGRAM_SND_TIMEOUT
;
778 BIO_ctrl(sbio
, BIO_CTRL_DGRAM_SET_SEND_TIMEOUT
, 0, &timeout
);
780 if (socket_mtu
> 28) {
781 SSL_set_options(con
, SSL_OP_NO_QUERY_MTU
);
782 SSL_set_mtu(con
, socket_mtu
- 28);
784 /* want to do MTU discovery */
785 BIO_ctrl(sbio
, BIO_CTRL_DGRAM_MTU_DISCOVER
, 0, NULL
);
787 sbio
= BIO_new_socket(s
, BIO_NOCLOSE
);
792 test
= BIO_new(BIO_f_nbio_test());
793 sbio
= BIO_push(test
, sbio
);
796 SSL_set_debug(con
, 1);
797 BIO_set_callback(sbio
, bio_dump_callback
);
798 BIO_set_callback_arg(sbio
, (char *) bio_c_out
);
801 SSL_set_msg_callback(con
, msg_cb
);
802 SSL_set_msg_callback_arg(con
, bio_c_out
);
805 SSL_set_tlsext_debug_callback(con
, tlsext_cb
);
806 SSL_set_tlsext_debug_arg(con
, bio_c_out
);
809 SSL_set_tlsext_status_type(con
, TLSEXT_STATUSTYPE_ocsp
);
810 SSL_CTX_set_tlsext_status_cb(ctx
, ocsp_resp_cb
);
811 SSL_CTX_set_tlsext_status_arg(ctx
, bio_c_out
);
814 SSL_set_bio(con
, sbio
, sbio
);
815 SSL_set_connect_state(con
);
817 /* ok, lets connect */
829 /* This is an ugly hack that does a lot of assumptions */
831 * We do have to handle multi-line responses which may come in a
832 * single packet or not. We therefore have to use BIO_gets() which
833 * does need a buffering BIO. So during the initial chitchat we do
834 * push a buffering BIO into the chain that is removed again later on
835 * to not disturb the rest of the s_client operation.
837 if (starttls_proto
== PROTO_SMTP
|| starttls_proto
== PROTO_LMTP
) {
839 BIO
*fbio
= BIO_new(BIO_f_buffer());
840 BIO_push(fbio
, sbio
);
841 /* wait for multi-line response to end from SMTP */
843 mbuf_len
= BIO_gets(fbio
, mbuf
, BUFSIZZ
);
845 while (mbuf_len
> 3 && mbuf
[3] == '-');
846 /* STARTTLS command requires EHLO... */
847 BIO_printf(fbio
, "%cHLO openssl.client.net\r\n",
848 starttls_proto
== PROTO_SMTP
? 'E' : 'L');
849 (void) BIO_flush(fbio
);
850 /* wait for multi-line response to end EHLO SMTP response */
852 mbuf_len
= BIO_gets(fbio
, mbuf
, BUFSIZZ
);
853 if (strstr(mbuf
, "STARTTLS"))
856 while (mbuf_len
> 3 && mbuf
[3] == '-');
857 (void) BIO_flush(fbio
);
862 "didn't find starttls in server response,"
864 BIO_printf(sbio
, "STARTTLS\r\n");
865 BIO_read(sbio
, sbuf
, BUFSIZZ
);
866 } else if (starttls_proto
== PROTO_POP3
) {
867 mbuf_len
= BIO_read(sbio
, mbuf
, BUFSIZZ
);
868 if (mbuf_len
== -1) {
869 BIO_printf(bio_err
, "BIO_read failed\n");
872 BIO_printf(sbio
, "STLS\r\n");
873 BIO_read(sbio
, sbuf
, BUFSIZZ
);
874 } else if (starttls_proto
== PROTO_IMAP
) {
876 BIO
*fbio
= BIO_new(BIO_f_buffer());
877 BIO_push(fbio
, sbio
);
878 BIO_gets(fbio
, mbuf
, BUFSIZZ
);
879 /* STARTTLS command requires CAPABILITY... */
880 BIO_printf(fbio
, ". CAPABILITY\r\n");
881 (void) BIO_flush(fbio
);
882 /* wait for multi-line CAPABILITY response */
884 mbuf_len
= BIO_gets(fbio
, mbuf
, BUFSIZZ
);
885 if (strstr(mbuf
, "STARTTLS"))
888 while (mbuf_len
> 3 && mbuf
[0] != '.');
889 (void) BIO_flush(fbio
);
894 "didn't found STARTTLS in server response,"
896 BIO_printf(sbio
, ". STARTTLS\r\n");
897 BIO_read(sbio
, sbuf
, BUFSIZZ
);
898 } else if (starttls_proto
== PROTO_FTP
) {
899 BIO
*fbio
= BIO_new(BIO_f_buffer());
900 BIO_push(fbio
, sbio
);
901 /* wait for multi-line response to end from FTP */
903 mbuf_len
= BIO_gets(fbio
, mbuf
, BUFSIZZ
);
905 while (mbuf_len
> 3 && mbuf
[3] == '-');
906 (void) BIO_flush(fbio
);
909 BIO_printf(sbio
, "AUTH TLS\r\n");
910 BIO_read(sbio
, sbuf
, BUFSIZZ
);
911 } else if (starttls_proto
== PROTO_XMPP
) {
913 BIO_printf(sbio
, "<stream:stream "
914 "xmlns:stream='http://etherx.jabber.org/streams' "
915 "xmlns='jabber:client' to='%s' version='1.0'>", xmpphost
? xmpphost
: host
);
916 seen
= BIO_read(sbio
, mbuf
, BUFSIZZ
);
922 while (!strstr(mbuf
, "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'") &&
923 !strstr(mbuf
, "<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"")) {
924 seen
= BIO_read(sbio
, mbuf
, BUFSIZZ
);
931 BIO_printf(sbio
, "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>");
932 seen
= BIO_read(sbio
, sbuf
, BUFSIZZ
);
934 if (!strstr(sbuf
, "<proceed"))
937 } else if (proxy
!= NULL
) {
938 BIO_printf(sbio
, "CONNECT %s HTTP/1.0\r\n\r\n", connect
);
939 mbuf_len
= BIO_read(sbio
, mbuf
, BUFSIZZ
);
940 if (mbuf_len
== -1) {
941 BIO_printf(bio_err
, "BIO_read failed\n");
946 struct pollfd pfd
[3]; /* stdin, stdout, socket */
949 if ((SSL_version(con
) == DTLS1_VERSION
) &&
950 DTLSv1_get_timeout(con
, &timeout
))
951 ptimeout
= timeout
.tv_sec
* 1000 + timeout
.tv_usec
/ 1000;
953 if (SSL_in_init(con
) && !SSL_total_renegotiations(con
)) {
961 BIO
*stmp
= BIO_new_file(sess_out
, "w");
963 PEM_write_bio_SSL_SESSION(stmp
, SSL_get_session(con
));
966 BIO_printf(bio_err
, "Error writing session file %s\n", sess_out
);
968 print_stuff(bio_c_out
, con
, full_log
);
972 if (starttls_proto
) {
973 BIO_write(bio_err
, mbuf
, mbuf_len
);
974 /* We don't need to know any more */
975 starttls_proto
= PROTO_OFF
;
979 BIO_printf(bio_c_out
, "drop connection and then reconnect\n");
981 SSL_set_connect_state(con
);
982 shutdown(SSL_get_fd(con
), SHUT_RD
);
983 close(SSL_get_fd(con
));
989 ssl_pending
= read_ssl
&& SSL_pending(con
);
996 pfd
[0].fd
= fileno(stdin
);
997 pfd
[0].events
= POLLIN
;
1000 pfd
[1].fd
= fileno(stdout
);
1001 pfd
[1].events
= POLLOUT
;
1005 pfd
[2].fd
= SSL_get_fd(con
);
1008 pfd
[2].events
|= POLLIN
;
1010 pfd
[2].events
|= POLLOUT
;
1012 /* printf("mode tty(%d %d%d) ssl(%d%d)\n",
1013 tty_on,read_tty,write_tty,read_ssl,write_ssl);*/
1015 i
= poll(pfd
, 3, ptimeout
);
1017 BIO_printf(bio_err
, "bad select %d\n",
1023 if ((SSL_version(con
) == DTLS1_VERSION
) && DTLSv1_handle_timeout(con
) > 0) {
1024 BIO_printf(bio_err
, "TIMEOUT occured\n");
1026 if (!ssl_pending
&& (pfd
[2].revents
& (POLLOUT
|POLLERR
|POLLNVAL
))) {
1027 if (pfd
[2].revents
& (POLLERR
|POLLNVAL
)) {
1028 BIO_printf(bio_err
, "poll error");
1031 k
= SSL_write(con
, &(cbuf
[cbuf_off
]),
1032 (unsigned int) cbuf_len
);
1033 switch (SSL_get_error(con
, k
)) {
1034 case SSL_ERROR_NONE
:
1039 /* we have done a write(con,NULL,0); */
1040 if (cbuf_len
<= 0) {
1043 } else { /* if (cbuf_len > 0) */
1048 case SSL_ERROR_WANT_WRITE
:
1049 BIO_printf(bio_c_out
, "write W BLOCK\n");
1053 case SSL_ERROR_WANT_READ
:
1054 BIO_printf(bio_c_out
, "write R BLOCK\n");
1059 case SSL_ERROR_WANT_X509_LOOKUP
:
1060 BIO_printf(bio_c_out
, "write X BLOCK\n");
1062 case SSL_ERROR_ZERO_RETURN
:
1063 if (cbuf_len
!= 0) {
1064 BIO_printf(bio_c_out
, "shutdown\n");
1073 case SSL_ERROR_SYSCALL
:
1074 if ((k
!= 0) || (cbuf_len
!= 0)) {
1075 BIO_printf(bio_err
, "write:errno=%d\n",
1084 ERR_print_errors(bio_err
);
1087 } else if (!ssl_pending
&&
1088 (pfd
[1].revents
& (POLLOUT
|POLLERR
|POLLNVAL
))) {
1089 if (pfd
[1].revents
& (POLLERR
|POLLNVAL
)) {
1090 BIO_printf(bio_err
, "poll error");
1093 i
= write(fileno(stdout
), &(sbuf
[sbuf_off
]), sbuf_len
);
1096 BIO_printf(bio_c_out
, "DONE\n");
1103 if (sbuf_len
<= 0) {
1107 } else if (ssl_pending
|| (pfd
[2].revents
& (POLLIN
|POLLHUP
))) {
1112 SSL_renegotiate(con
);
1117 k
= SSL_read(con
, sbuf
, 1024 /* BUFSIZZ */ );
1119 switch (SSL_get_error(con
, k
)) {
1120 case SSL_ERROR_NONE
:
1129 case SSL_ERROR_WANT_WRITE
:
1130 BIO_printf(bio_c_out
, "read W BLOCK\n");
1134 case SSL_ERROR_WANT_READ
:
1135 BIO_printf(bio_c_out
, "read R BLOCK\n");
1138 if ((read_tty
== 0) && (write_ssl
== 0))
1141 case SSL_ERROR_WANT_X509_LOOKUP
:
1142 BIO_printf(bio_c_out
, "read X BLOCK\n");
1144 case SSL_ERROR_SYSCALL
:
1146 BIO_printf(bio_err
, "read:errno=%d\n", ret
);
1148 case SSL_ERROR_ZERO_RETURN
:
1149 BIO_printf(bio_c_out
, "closed\n");
1153 ERR_print_errors(bio_err
);
1157 } else if (pfd
[0].revents
) {
1158 if (pfd
[0].revents
& (POLLERR
|POLLNVAL
)) {
1159 BIO_printf(bio_err
, "poll error");
1165 i
= read(fileno(stdin
), cbuf
, BUFSIZZ
/ 2);
1167 /* both loops are skipped when i <= 0 */
1168 for (j
= 0; j
< i
; j
++)
1169 if (cbuf
[j
] == '\n')
1171 for (j
= i
- 1; j
>= 0; j
--) {
1172 cbuf
[j
+ lf_num
] = cbuf
[j
];
1173 if (cbuf
[j
] == '\n') {
1176 cbuf
[j
+ lf_num
] = '\r';
1179 assert(lf_num
== 0);
1181 i
= read(fileno(stdin
), cbuf
, BUFSIZZ
);
1183 if ((!c_ign_eof
) && ((i
<= 0) || (cbuf
[0] == 'Q'))) {
1184 BIO_printf(bio_err
, "DONE\n");
1188 if ((!c_ign_eof
) && (cbuf
[0] == 'R')) {
1189 BIO_printf(bio_err
, "RENEGOTIATING\n");
1190 SSL_renegotiate(con
);
1205 print_stuff(bio_c_out
, con
, full_log
);
1207 shutdown(SSL_get_fd(con
), SHUT_RD
);
1208 close(SSL_get_fd(con
));
1212 print_stuff(bio_c_out
, con
, 1);
1219 X509_VERIFY_PARAM_free(vpm
);
1220 freezero(cbuf
, BUFSIZZ
);
1221 freezero(sbuf
, BUFSIZZ
);
1222 freezero(mbuf
, BUFSIZZ
);
1223 if (bio_c_out
!= NULL
) {
1224 BIO_free(bio_c_out
);
1233 print_stuff(BIO
* bio
, SSL
* s
, int full
)
1237 static const char *space
= " ";
1239 STACK_OF(X509
) * sk
;
1240 STACK_OF(X509_NAME
) * sk2
;
1241 const SSL_CIPHER
*c
;
1244 unsigned char *exportedkeymat
;
1247 int got_a_chain
= 0;
1249 sk
= SSL_get_peer_cert_chain(s
);
1251 got_a_chain
= 1; /* we don't have it for SSL2
1254 BIO_printf(bio
, "---\nCertificate chain\n");
1255 for (i
= 0; i
< sk_X509_num(sk
); i
++) {
1256 X509_NAME_oneline(X509_get_subject_name(
1257 sk_X509_value(sk
, i
)), buf
, sizeof buf
);
1258 BIO_printf(bio
, "%2d s:%s\n", i
, buf
);
1259 X509_NAME_oneline(X509_get_issuer_name(
1260 sk_X509_value(sk
, i
)), buf
, sizeof buf
);
1261 BIO_printf(bio
, " i:%s\n", buf
);
1263 PEM_write_bio_X509(bio
, sk_X509_value(sk
, i
));
1266 BIO_printf(bio
, "---\n");
1267 peer
= SSL_get_peer_certificate(s
);
1269 BIO_printf(bio
, "Server certificate\n");
1270 if (!(c_showcerts
&& got_a_chain
)) /* Redundant if we
1273 PEM_write_bio_X509(bio
, peer
);
1274 X509_NAME_oneline(X509_get_subject_name(peer
),
1276 BIO_printf(bio
, "subject=%s\n", buf
);
1277 X509_NAME_oneline(X509_get_issuer_name(peer
),
1279 BIO_printf(bio
, "issuer=%s\n", buf
);
1281 BIO_printf(bio
, "no peer certificate available\n");
1283 sk2
= SSL_get_client_CA_list(s
);
1284 if ((sk2
!= NULL
) && (sk_X509_NAME_num(sk2
) > 0)) {
1285 BIO_printf(bio
, "---\nAcceptable client certificate CA names\n");
1286 for (i
= 0; i
< sk_X509_NAME_num(sk2
); i
++) {
1287 xn
= sk_X509_NAME_value(sk2
, i
);
1288 X509_NAME_oneline(xn
, buf
, sizeof(buf
));
1289 BIO_write(bio
, buf
, strlen(buf
));
1290 BIO_write(bio
, "\n", 1);
1293 BIO_printf(bio
, "---\nNo client certificate CA names sent\n");
1295 p
= SSL_get_shared_ciphers(s
, buf
, sizeof buf
);
1298 * This works only for SSL 2. In later protocol
1299 * versions, the client does not know what other
1300 * ciphers (in addition to the one to be used in the
1301 * current connection) the server supports.
1304 BIO_printf(bio
, "---\nCiphers common between both SSL endpoints:\n");
1308 BIO_write(bio
, space
, 15 - j
% 25);
1311 BIO_write(bio
, ((i
% 3) ? " " : "\n"), 1);
1313 BIO_write(bio
, p
, 1);
1318 BIO_write(bio
, "\n", 1);
1321 ssl_print_tmp_key(bio
, s
);
1323 BIO_printf(bio
, "---\nSSL handshake has read %ld bytes and written %ld bytes\n",
1324 BIO_number_read(SSL_get_rbio(s
)),
1325 BIO_number_written(SSL_get_wbio(s
)));
1327 BIO_printf(bio
, (SSL_cache_hit(s
) ? "---\nReused, " : "---\nNew, "));
1328 c
= SSL_get_current_cipher(s
);
1329 BIO_printf(bio
, "%s, Cipher is %s\n",
1330 SSL_CIPHER_get_version(c
),
1331 SSL_CIPHER_get_name(c
));
1334 pktmp
= X509_get_pubkey(peer
);
1335 BIO_printf(bio
, "Server public key is %d bit\n",
1336 EVP_PKEY_bits(pktmp
));
1337 EVP_PKEY_free(pktmp
);
1339 BIO_printf(bio
, "Secure Renegotiation IS%s supported\n",
1340 SSL_get_secure_renegotiation_support(s
) ? "" : " NOT");
1342 /* Compression is not supported and will always be none. */
1343 BIO_printf(bio
, "Compression: NONE\n");
1344 BIO_printf(bio
, "Expansion: NONE\n");
1348 /* Print out local port of connection: useful for debugging */
1350 struct sockaddr_in ladd
;
1351 socklen_t ladd_size
= sizeof(ladd
);
1352 sock
= SSL_get_fd(s
);
1353 getsockname(sock
, (struct sockaddr
*) & ladd
, &ladd_size
);
1354 BIO_printf(bio_c_out
, "LOCAL PORT is %u\n", ntohs(ladd
.sin_port
));
1359 const unsigned char *proto
;
1360 unsigned int proto_len
;
1361 SSL_get0_alpn_selected(s
, &proto
, &proto_len
);
1362 if (proto_len
> 0) {
1363 BIO_printf(bio
, "ALPN protocol: ");
1364 BIO_write(bio
, proto
, proto_len
);
1365 BIO_write(bio
, "\n", 1);
1367 BIO_printf(bio
, "No ALPN negotiated\n");
1370 #ifndef OPENSSL_NO_SRTP
1372 SRTP_PROTECTION_PROFILE
*srtp_profile
= SSL_get_selected_srtp_profile(s
);
1375 BIO_printf(bio
, "SRTP Extension negotiated, profile=%s\n",
1376 srtp_profile
->name
);
1380 SSL_SESSION_print(bio
, SSL_get_session(s
));
1381 if (keymatexportlabel
!= NULL
) {
1382 BIO_printf(bio
, "Keying material exporter:\n");
1383 BIO_printf(bio
, " Label: '%s'\n", keymatexportlabel
);
1384 BIO_printf(bio
, " Length: %i bytes\n", keymatexportlen
);
1385 exportedkeymat
= malloc(keymatexportlen
);
1386 if (exportedkeymat
!= NULL
) {
1387 if (!SSL_export_keying_material(s
, exportedkeymat
,
1390 strlen(keymatexportlabel
),
1392 BIO_printf(bio
, " Error\n");
1394 BIO_printf(bio
, " Keying material: ");
1395 for (i
= 0; i
< keymatexportlen
; i
++)
1396 BIO_printf(bio
, "%02X",
1398 BIO_printf(bio
, "\n");
1400 free(exportedkeymat
);
1403 BIO_printf(bio
, "---\n");
1405 /* flush, or debugging output gets mixed with http response */
1406 (void) BIO_flush(bio
);
1411 ocsp_resp_cb(SSL
* s
, void *arg
)
1413 const unsigned char *p
;
1416 len
= SSL_get_tlsext_status_ocsp_resp(s
, &p
);
1417 BIO_puts(arg
, "OCSP response: ");
1419 BIO_puts(arg
, "no response sent\n");
1422 rsp
= d2i_OCSP_RESPONSE(NULL
, &p
, len
);
1424 BIO_puts(arg
, "response parse error\n");
1425 BIO_dump_indent(arg
, (char *) p
, len
, 4);
1428 BIO_puts(arg
, "\n======================================\n");
1429 OCSP_RESPONSE_print(arg
, rsp
, 0);
1430 BIO_puts(arg
, "======================================\n");
1431 OCSP_RESPONSE_free(rsp
);