summaryrefslogtreecommitdiff
path: root/src/usr.bin/openssl/s_client.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr.bin/openssl/s_client.c')
-rw-r--r--src/usr.bin/openssl/s_client.c26
1 files changed, 1 insertions, 25 deletions
diff --git a/src/usr.bin/openssl/s_client.c b/src/usr.bin/openssl/s_client.c
index 25d4c0c5dd..12c9bd2c2d 100644
--- a/src/usr.bin/openssl/s_client.c
+++ b/src/usr.bin/openssl/s_client.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s_client.c,v 1.5 2014/10/22 13:51:31 jsing Exp $ */ 1/* $OpenBSD: s_client.c,v 1.6 2014/11/06 14:50:12 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -179,10 +179,8 @@ extern int verify_return_error;
179static int c_nbio = 0; 179static int c_nbio = 0;
180static int c_Pause = 0; 180static int c_Pause = 0;
181static int c_debug = 0; 181static int c_debug = 0;
182#ifndef OPENSSL_NO_TLSEXT
183static int c_tlsextdebug = 0; 182static int c_tlsextdebug = 0;
184static int c_status_req = 0; 183static int c_status_req = 0;
185#endif
186static int c_msg = 0; 184static int c_msg = 0;
187static int c_showcerts = 0; 185static int c_showcerts = 0;
188 186
@@ -191,9 +189,7 @@ static int keymatexportlen = 20;
191 189
192static void sc_usage(void); 190static void sc_usage(void);
193static void print_stuff(BIO * berr, SSL * con, int full); 191static void print_stuff(BIO * berr, SSL * con, int full);
194#ifndef OPENSSL_NO_TLSEXT
195static int ocsp_resp_cb(SSL * s, void *arg); 192static int ocsp_resp_cb(SSL * s, void *arg);
196#endif
197static BIO *bio_c_out = NULL; 193static BIO *bio_c_out = NULL;
198static int c_quiet = 0; 194static int c_quiet = 0;
199static int c_ign_eof = 0; 195static int c_ign_eof = 0;
@@ -251,7 +247,6 @@ sc_usage(void)
251#endif 247#endif
252 BIO_printf(bio_err, " -sess_out arg - file to write SSL session to\n"); 248 BIO_printf(bio_err, " -sess_out arg - file to write SSL session to\n");
253 BIO_printf(bio_err, " -sess_in arg - file to read SSL session from\n"); 249 BIO_printf(bio_err, " -sess_in arg - file to read SSL session from\n");
254#ifndef OPENSSL_NO_TLSEXT
255 BIO_printf(bio_err, " -servername host - Set TLS extension servername in ClientHello\n"); 250 BIO_printf(bio_err, " -servername host - Set TLS extension servername in ClientHello\n");
256 BIO_printf(bio_err, " -tlsextdebug - hex dump of all TLS extensions received\n"); 251 BIO_printf(bio_err, " -tlsextdebug - hex dump of all TLS extensions received\n");
257 BIO_printf(bio_err, " -status - request certificate status from server\n"); 252 BIO_printf(bio_err, " -status - request certificate status from server\n");
@@ -259,7 +254,6 @@ sc_usage(void)
259#ifndef OPENSSL_NO_NEXTPROTONEG 254#ifndef OPENSSL_NO_NEXTPROTONEG
260 BIO_printf(bio_err, " -nextprotoneg arg - enable NPN extension, considering named protocols supported (comma-separated list)\n"); 255 BIO_printf(bio_err, " -nextprotoneg arg - enable NPN extension, considering named protocols supported (comma-separated list)\n");
261#endif 256#endif
262#endif
263#ifndef OPENSSL_NO_SRTP 257#ifndef OPENSSL_NO_SRTP
264 BIO_printf(bio_err, " -use_srtp profiles - Offer SRTP key management with a colon-separated profile list\n"); 258 BIO_printf(bio_err, " -use_srtp profiles - Offer SRTP key management with a colon-separated profile list\n");
265#endif 259#endif
@@ -267,7 +261,6 @@ sc_usage(void)
267 BIO_printf(bio_err, " -keymatexportlen len - Export len bytes of keying material (default 20)\n"); 261 BIO_printf(bio_err, " -keymatexportlen len - Export len bytes of keying material (default 20)\n");
268} 262}
269 263
270#ifndef OPENSSL_NO_TLSEXT
271 264
272/* This is a context that we pass to callbacks */ 265/* This is a context that we pass to callbacks */
273typedef struct tlsextctx_st { 266typedef struct tlsextctx_st {
@@ -324,7 +317,6 @@ next_proto_cb(SSL * s, unsigned char **out, unsigned char *outlen, const unsigne
324 return SSL_TLSEXT_ERR_OK; 317 return SSL_TLSEXT_ERR_OK;
325} 318}
326#endif /* ndef OPENSSL_NO_NEXTPROTONEG */ 319#endif /* ndef OPENSSL_NO_NEXTPROTONEG */
327#endif
328 320
329enum { 321enum {
330 PROTO_OFF = 0, 322 PROTO_OFF = 0,
@@ -378,14 +370,12 @@ s_client_main(int argc, char **argv)
378 ENGINE *ssl_client_engine = NULL; 370 ENGINE *ssl_client_engine = NULL;
379#endif 371#endif
380 ENGINE *e = NULL; 372 ENGINE *e = NULL;
381#ifndef OPENSSL_NO_TLSEXT
382 char *servername = NULL; 373 char *servername = NULL;
383 tlsextctx tlsextcbp = 374 tlsextctx tlsextcbp =
384 {NULL, 0}; 375 {NULL, 0};
385#ifndef OPENSSL_NO_NEXTPROTONEG 376#ifndef OPENSSL_NO_NEXTPROTONEG
386 const char *next_proto_neg_in = NULL; 377 const char *next_proto_neg_in = NULL;
387#endif 378#endif
388#endif
389 char *sess_in = NULL; 379 char *sess_in = NULL;
390 char *sess_out = NULL; 380 char *sess_out = NULL;
391 struct sockaddr peer; 381 struct sockaddr peer;
@@ -475,12 +465,10 @@ s_client_main(int argc, char **argv)
475 c_Pause = 1; 465 c_Pause = 1;
476 else if (strcmp(*argv, "-debug") == 0) 466 else if (strcmp(*argv, "-debug") == 0)
477 c_debug = 1; 467 c_debug = 1;
478#ifndef OPENSSL_NO_TLSEXT
479 else if (strcmp(*argv, "-tlsextdebug") == 0) 468 else if (strcmp(*argv, "-tlsextdebug") == 0)
480 c_tlsextdebug = 1; 469 c_tlsextdebug = 1;
481 else if (strcmp(*argv, "-status") == 0) 470 else if (strcmp(*argv, "-status") == 0)
482 c_status_req = 1; 471 c_status_req = 1;
483#endif
484 else if (strcmp(*argv, "-msg") == 0) 472 else if (strcmp(*argv, "-msg") == 0)
485 c_msg = 1; 473 c_msg = 1;
486 else if (strcmp(*argv, "-showcerts") == 0) 474 else if (strcmp(*argv, "-showcerts") == 0)
@@ -548,7 +536,6 @@ s_client_main(int argc, char **argv)
548 else if (strcmp(*argv, "-no_comp") == 0) { 536 else if (strcmp(*argv, "-no_comp") == 0) {
549 off |= SSL_OP_NO_COMPRESSION; 537 off |= SSL_OP_NO_COMPRESSION;
550 } 538 }
551#ifndef OPENSSL_NO_TLSEXT
552 else if (strcmp(*argv, "-no_ticket") == 0) { 539 else if (strcmp(*argv, "-no_ticket") == 0) {
553 off |= SSL_OP_NO_TICKET; 540 off |= SSL_OP_NO_TICKET;
554 } 541 }
@@ -559,7 +546,6 @@ s_client_main(int argc, char **argv)
559 next_proto_neg_in = *(++argv); 546 next_proto_neg_in = *(++argv);
560 } 547 }
561#endif 548#endif
562#endif
563 else if (strcmp(*argv, "-serverpref") == 0) 549 else if (strcmp(*argv, "-serverpref") == 0)
564 off |= SSL_OP_CIPHER_SERVER_PREFERENCE; 550 off |= SSL_OP_CIPHER_SERVER_PREFERENCE;
565 else if (strcmp(*argv, "-legacy_renegotiation") == 0) 551 else if (strcmp(*argv, "-legacy_renegotiation") == 0)
@@ -611,14 +597,12 @@ s_client_main(int argc, char **argv)
611 } else if (strcmp(*argv, "-6") == 0) { 597 } else if (strcmp(*argv, "-6") == 0) {
612 af = AF_INET6; 598 af = AF_INET6;
613 } 599 }
614#ifndef OPENSSL_NO_TLSEXT
615 else if (strcmp(*argv, "-servername") == 0) { 600 else if (strcmp(*argv, "-servername") == 0) {
616 if (--argc < 1) 601 if (--argc < 1)
617 goto bad; 602 goto bad;
618 servername = *(++argv); 603 servername = *(++argv);
619 /* meth=TLSv1_client_method(); */ 604 /* meth=TLSv1_client_method(); */
620 } 605 }
621#endif
622#ifndef OPENSSL_NO_SRTP 606#ifndef OPENSSL_NO_SRTP
623 else if (strcmp(*argv, "-use_srtp") == 0) { 607 else if (strcmp(*argv, "-use_srtp") == 0) {
624 if (--argc < 1) 608 if (--argc < 1)
@@ -777,13 +761,11 @@ bad:
777 ERR_print_errors(bio_err); 761 ERR_print_errors(bio_err);
778 /* goto end; */ 762 /* goto end; */
779 } 763 }
780#ifndef OPENSSL_NO_TLSEXT
781 if (servername != NULL) { 764 if (servername != NULL) {
782 tlsextcbp.biodebug = bio_err; 765 tlsextcbp.biodebug = bio_err;
783 SSL_CTX_set_tlsext_servername_callback(ctx, ssl_servername_cb); 766 SSL_CTX_set_tlsext_servername_callback(ctx, ssl_servername_cb);
784 SSL_CTX_set_tlsext_servername_arg(ctx, &tlsextcbp); 767 SSL_CTX_set_tlsext_servername_arg(ctx, &tlsextcbp);
785 } 768 }
786#endif
787 769
788 con = SSL_new(ctx); 770 con = SSL_new(ctx);
789 if (sess_in) { 771 if (sess_in) {
@@ -806,7 +788,6 @@ bad:
806 SSL_set_session(con, sess); 788 SSL_set_session(con, sess);
807 SSL_SESSION_free(sess); 789 SSL_SESSION_free(sess);
808 } 790 }
809#ifndef OPENSSL_NO_TLSEXT
810 if (servername != NULL) { 791 if (servername != NULL) {
811 if (!SSL_set_tlsext_host_name(con, servername)) { 792 if (!SSL_set_tlsext_host_name(con, servername)) {
812 BIO_printf(bio_err, "Unable to set TLS servername extension.\n"); 793 BIO_printf(bio_err, "Unable to set TLS servername extension.\n");
@@ -814,7 +795,6 @@ bad:
814 goto end; 795 goto end;
815 } 796 }
816 } 797 }
817#endif
818/* SSL_set_cipher_list(con,"RC4-MD5"); */ 798/* SSL_set_cipher_list(con,"RC4-MD5"); */
819 799
820re_start: 800re_start:
@@ -881,7 +861,6 @@ re_start:
881 SSL_set_msg_callback(con, msg_cb); 861 SSL_set_msg_callback(con, msg_cb);
882 SSL_set_msg_callback_arg(con, bio_c_out); 862 SSL_set_msg_callback_arg(con, bio_c_out);
883 } 863 }
884#ifndef OPENSSL_NO_TLSEXT
885 if (c_tlsextdebug) { 864 if (c_tlsextdebug) {
886 SSL_set_tlsext_debug_callback(con, tlsext_cb); 865 SSL_set_tlsext_debug_callback(con, tlsext_cb);
887 SSL_set_tlsext_debug_arg(con, bio_c_out); 866 SSL_set_tlsext_debug_arg(con, bio_c_out);
@@ -891,7 +870,6 @@ re_start:
891 SSL_CTX_set_tlsext_status_cb(ctx, ocsp_resp_cb); 870 SSL_CTX_set_tlsext_status_cb(ctx, ocsp_resp_cb);
892 SSL_CTX_set_tlsext_status_arg(ctx, bio_c_out); 871 SSL_CTX_set_tlsext_status_arg(ctx, bio_c_out);
893 } 872 }
894#endif
895 873
896 SSL_set_bio(con, sbio, sbio); 874 SSL_set_bio(con, sbio, sbio);
897 SSL_set_connect_state(con); 875 SSL_set_connect_state(con);
@@ -1472,7 +1450,6 @@ print_stuff(BIO * bio, SSL * s, int full)
1472 (void) BIO_flush(bio); 1450 (void) BIO_flush(bio);
1473} 1451}
1474 1452
1475#ifndef OPENSSL_NO_TLSEXT
1476 1453
1477static int 1454static int
1478ocsp_resp_cb(SSL * s, void *arg) 1455ocsp_resp_cb(SSL * s, void *arg)
@@ -1499,4 +1476,3 @@ ocsp_resp_cb(SSL * s, void *arg)
1499 return 1; 1476 return 1;
1500} 1477}
1501 1478
1502#endif