summaryrefslogtreecommitdiff
path: root/src/usr.bin/openssl/s_client.c
diff options
context:
space:
mode:
authorlandry <>2015-08-11 05:01:03 +0000
committerlandry <>2015-08-11 05:01:03 +0000
commit2ea8009a06abaf0096774d1fa3d0d7f6d2f98cf5 (patch)
tree266b4b3457383ba096f14212a40b0a44be6be92d /src/usr.bin/openssl/s_client.c
parentf8b563fb5ba1524c821d37308f4e6abfc866bc3f (diff)
downloadopenbsd-2ea8009a06abaf0096774d1fa3d0d7f6d2f98cf5.tar.gz
openbsd-2ea8009a06abaf0096774d1fa3d0d7f6d2f98cf5.tar.bz2
openbsd-2ea8009a06abaf0096774d1fa3d0d7f6d2f98cf5.zip
Improve openssl s_client -starttls xmpp support.
From https://rt.openssl.org/Ticket/Display.html?id=2860&user=guest&pass=guest - add a -xmpphost option to specify the xmpp virtual host - fix an infinite loop when the vhost isnt what the server expects - fix communication with openfire & prosody servers with tweaks & ok bcook@ doug@ manpage bits jmc@
Diffstat (limited to 'src/usr.bin/openssl/s_client.c')
-rw-r--r--src/usr.bin/openssl/s_client.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/usr.bin/openssl/s_client.c b/src/usr.bin/openssl/s_client.c
index 14e1a4bab9..aa803e8baa 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.14 2015/07/17 16:07:44 doug Exp $ */ 1/* $OpenBSD: s_client.c,v 1.15 2015/08/11 05:01:03 landry 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 *
@@ -237,6 +237,7 @@ sc_usage(void)
237 BIO_printf(bio_err, " 'prot' defines which one to assume. Currently,\n"); 237 BIO_printf(bio_err, " 'prot' defines which one to assume. Currently,\n");
238 BIO_printf(bio_err, " only \"smtp\", \"lmtp\", \"pop3\", \"imap\", \"ftp\" and \"xmpp\"\n"); 238 BIO_printf(bio_err, " only \"smtp\", \"lmtp\", \"pop3\", \"imap\", \"ftp\" and \"xmpp\"\n");
239 BIO_printf(bio_err, " are supported.\n"); 239 BIO_printf(bio_err, " are supported.\n");
240 BIO_printf(bio_err, " -xmpphost host - connect to this virtual host on the xmpp server\n");
240#ifndef OPENSSL_NO_ENGINE 241#ifndef OPENSSL_NO_ENGINE
241 BIO_printf(bio_err, " -engine id - Initialise and use the specified engine\n"); 242 BIO_printf(bio_err, " -engine id - Initialise and use the specified engine\n");
242#endif 243#endif
@@ -334,6 +335,7 @@ s_client_main(int argc, char **argv)
334 char *port = PORT_STR; 335 char *port = PORT_STR;
335 int full_log = 1; 336 int full_log = 1;
336 char *host = SSL_HOST_NAME; 337 char *host = SSL_HOST_NAME;
338 char *xmpphost = NULL;
337 char *proxy = NULL, *connect = NULL; 339 char *proxy = NULL, *connect = NULL;
338 char *cert_file = NULL, *key_file = NULL; 340 char *cert_file = NULL, *key_file = NULL;
339 int cert_format = FORMAT_PEM, key_format = FORMAT_PEM; 341 int cert_format = FORMAT_PEM, key_format = FORMAT_PEM;
@@ -414,6 +416,10 @@ s_client_main(int argc, char **argv)
414 if (--argc < 1) 416 if (--argc < 1)
415 goto bad; 417 goto bad;
416 proxy = *(++argv); 418 proxy = *(++argv);
419 } else if (strcmp(*argv,"-xmpphost") == 0) {
420 if (--argc < 1)
421 goto bad;
422 xmpphost= *(++argv);
417 } else if (strcmp(*argv, "-verify") == 0) { 423 } else if (strcmp(*argv, "-verify") == 0) {
418 verify = SSL_VERIFY_PEER; 424 verify = SSL_VERIFY_PEER;
419 if (--argc < 1) 425 if (--argc < 1)
@@ -982,13 +988,20 @@ re_start:
982 int seen = 0; 988 int seen = 0;
983 BIO_printf(sbio, "<stream:stream " 989 BIO_printf(sbio, "<stream:stream "
984 "xmlns:stream='http://etherx.jabber.org/streams' " 990 "xmlns:stream='http://etherx.jabber.org/streams' "
985 "xmlns='jabber:client' to='%s' version='1.0'>", host); 991 "xmlns='jabber:client' to='%s' version='1.0'>", xmpphost ? xmpphost : host);
986 seen = BIO_read(sbio, mbuf, BUFSIZZ); 992 seen = BIO_read(sbio, mbuf, BUFSIZZ);
993
994 if (seen <= 0)
995 goto shut;
996
987 mbuf[seen] = 0; 997 mbuf[seen] = 0;
988 while (!strstr(mbuf, "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'")) { 998 while (!strstr(mbuf, "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'") &&
989 if (strstr(mbuf, "/stream:features>")) 999 !strstr(mbuf, "<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"")) {
990 goto shut;
991 seen = BIO_read(sbio, mbuf, BUFSIZZ); 1000 seen = BIO_read(sbio, mbuf, BUFSIZZ);
1001
1002 if (seen <= 0)
1003 goto shut;
1004
992 mbuf[seen] = 0; 1005 mbuf[seen] = 0;
993 } 1006 }
994 BIO_printf(sbio, "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>"); 1007 BIO_printf(sbio, "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>");