diff options
author | Lutz Jänicke <jaenicke@openssl.org> | 2007-02-21 18:20:41 +0000 |
---|---|---|
committer | Lutz Jänicke <jaenicke@openssl.org> | 2007-02-21 18:20:41 +0000 |
commit | 8d72476e2b4a00b9702d50e5b57a95ba9c32e41e (patch) | |
tree | b216a78433cc43a7f07a37b7d757ea705f23afea /apps/s_client.c | |
parent | 02756aa8ba36af6e718d7a07c4e6bd8ad12e7ba1 (diff) |
Extend SMTP and IMAP protocol handling to perform the required
EHLO or CAPABILITY handshake before sending STARTTLS
Submitted by: Goetz Babin-Ebell <goetz@shomitefo.de>
Diffstat (limited to 'apps/s_client.c')
-rw-r--r-- | apps/s_client.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/apps/s_client.c b/apps/s_client.c index 58e317a1a2..633d110f79 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -914,12 +914,27 @@ re_start: /* This is an ugly hack that does a lot of assumptions */ if (starttls_proto == PROTO_SMTP) { + int foundit=0; /* wait for multi-line response to end from SMTP */ do { mbuf_len = BIO_read(sbio,mbuf,BUFSIZZ); } while (mbuf_len>3 && mbuf[3]=='-'); + /* STARTTLS command requires EHLO... */ + BIO_printf(sbio,"EHLO openssl.client.net\r\n"); + /* wait for multi-line response to end EHLO SMTP response */ + do + { + mbuf_len = BIO_read(sbio,mbuf,BUFSIZZ); + if (strstr(mbuf,"STARTTLS")) + foundit=1; + } + while (mbuf_len>3 && mbuf[3]=='-'); + if (!foundit) + BIO_printf(bio_err, + "didn't found starttls in server response," + " try anyway...\n"); BIO_printf(sbio,"STARTTLS\r\n"); BIO_read(sbio,sbuf,BUFSIZZ); } @@ -931,8 +946,23 @@ re_start: } else if (starttls_proto == PROTO_IMAP) { + int foundit=0; BIO_read(sbio,mbuf,BUFSIZZ); - BIO_printf(sbio,"0 STARTTLS\r\n"); + /* STARTTLS command requires CAPABILITY... */ + BIO_printf(sbio,". CAPABILITY\r\n"); + /* wait for multi-line CAPABILITY response */ + do + { + mbuf_len = BIO_read(sbio,mbuf,BUFSIZZ); + if (strstr(mbuf,"STARTTLS")) + foundit=1; + } + while (mbuf_len>3); + if (!foundit) + BIO_printf(bio_err, + "didn't found STARTTLS in server response," + " try anyway...\n"); + BIO_printf(sbio,". STARTTLS\r\n"); BIO_read(sbio,sbuf,BUFSIZZ); } else if (starttls_proto == PROTO_FTP) |