diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2015-09-18 23:49:46 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2015-09-18 23:51:11 +0200 |
commit | f259c7a040fa0822b3c630ee7b00777db4f6c7f0 (patch) | |
tree | a5d64aa6fef8ea2e05ccaba41c3738b527c6fe83 /src/socket.c | |
parent | 8abd3cb87cddcf408e8f760c505013488820c96c (diff) | |
download | gnutls-f259c7a040fa0822b3c630ee7b00777db4f6c7f0.tar.gz |
tools: added xmpp into the starttls-proto options
Diffstat (limited to 'src/socket.c')
-rw-r--r-- | src/socket.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/socket.c b/src/socket.c index e0da89ab57..cac9634466 100644 --- a/src/socket.c +++ b/src/socket.c @@ -177,6 +177,8 @@ ssize_t wait_for_text(int fd, const char *txt, unsigned txt_size) void socket_starttls(socket_st * socket, const char *app_proto) { + char buf[512]; + if (socket->secure) return; @@ -188,7 +190,8 @@ socket_starttls(socket_st * socket, const char *app_proto) printf("Negotiating SMTP STARTTLS\n"); wait_for_text(socket->fd, "220 ", 4); - send_line(socket->fd, "EHLO mail.example.com\n"); + snprintf(buf, sizeof(buf), "EHLO %s\n", socket->hostname); + send_line(socket->fd, buf); wait_for_text(socket->fd, "250 ", 4); send_line(socket->fd, "STARTTLS\n"); wait_for_text(socket->fd, "220 ", 4); @@ -200,6 +203,15 @@ socket_starttls(socket_st * socket, const char *app_proto) wait_for_text(socket->fd, "a OK", 4); send_line(socket->fd, "a STARTTLS\r\n"); wait_for_text(socket->fd, "a OK", 4); + } else if (strcasecmp(app_proto, "xmpp") == 0) { + if (socket->verbose) + printf("Negotiating XMPP STARTTLS\n"); + + snprintf(buf, sizeof(buf), "<stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' to='%s' version='1.0'>\n", socket->hostname); + send_line(socket->fd, buf); + wait_for_text(socket->fd, "<?", 2); + send_line(socket->fd, "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>"); + wait_for_text(socket->fd, "<proceed", 8); } else if (strcasecmp(app_proto, "ldap") == 0) { if (socket->verbose) printf("Negotiating LDAP STARTTLS\n"); |