Hi folks,
my attempt to implement IMAP4rev1's STARTTLS command in s_client. Tested
against openssl-0.9.7i.

Cheers,
-jkt

-- 
cd /local/pub && more beer > /dev/mouth
--- apps/s_client.c.orig        2005-02-19 11:17:25.000000000 +0100
+++ apps/s_client.c     2006-06-01 02:11:06.000000000 +0200
@@ -220,7 +220,7 @@
        BIO_printf(bio_err," -starttls prot - use the STARTTLS command before 
starting TLS\n");
        BIO_printf(bio_err,"                 for those protocols that support 
it, where\n");
        BIO_printf(bio_err,"                 'prot' defines which one to 
assume.  Currently,\n");
-       BIO_printf(bio_err,"                 only \"smtp\" and \"pop3\" are 
supported.\n");
+       BIO_printf(bio_err,"                 only \"smtp\", \"pop3\" and 
\"imap\" are supported.\n");
 #ifndef OPENSSL_NO_ENGINE
        BIO_printf(bio_err," -engine id    - Initialise and use the specified 
engine\n");
 #endif
@@ -421,6 +421,8 @@
                                starttls_proto = 1;
                        else if (strcmp(*argv,"pop3") == 0)
                                starttls_proto = 2;
+                       else if (strcmp(*argv,"imap") == 0)
+                               starttls_proto = 3;
                        else
                                goto bad;
                        }
@@ -600,12 +602,18 @@
                BIO_printf(sbio,"STARTTLS\r\n");
                BIO_read(sbio,sbuf,BUFSIZZ);
                }
-       if (starttls_proto == 2)
+       else if (starttls_proto == 2)
                {
                BIO_read(sbio,mbuf,BUFSIZZ);
                BIO_printf(sbio,"STLS\r\n");
                BIO_read(sbio,sbuf,BUFSIZZ);
                }
+       else if (starttls_proto == 3)
+               {
+               BIO_read(sbio,mbuf,BUFSIZZ);
+               BIO_printf(sbio,"0 STARTTLS\r\n");
+               BIO_read(sbio,sbuf,BUFSIZZ);
+               }
 
        for (;;)
                {

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to