]> granicus.if.org Git - curl/commitdiff
imap: Added support for the STARTTLS capability (Part One)
authorSteve Holme <steve_holme@hotmail.com>
Sun, 10 Feb 2013 12:13:55 +0000 (12:13 +0000)
committerSteve Holme <steve_holme@hotmail.com>
Sun, 10 Feb 2013 12:13:55 +0000 (12:13 +0000)
Introduced detection of the STARTTLS capability, in order to add support
for TLS upgrades without unconditionally sending the STARTTLS command.

lib/imap.c
lib/imap.h

index 9310ee568d8df87839543665cdec180ba1c3f872..efc2f5c57e8f9ad9e2f0411e952774e2c1ffb5bb 100644 (file)
@@ -371,8 +371,12 @@ static int imap_endofresp(struct pingpong *pp, int *resp)
               line[wordlen] != '\n';)
           wordlen++;
 
+        /* Does the server support the STARTTLS capability? */
+        if(len >= 8 && !memcmp(line, "STARTTLS", 8))
+          imapc->tls_supported = TRUE;
+
         /* Has the server explicitly disabled clear text authentication? */
-        if(wordlen == 13 && !memcmp(line, "LOGINDISABLED", 13))
+        else if(wordlen == 13 && !memcmp(line, "LOGINDISABLED", 13))
           imapc->login_disabled = TRUE;
 
         /* Does the server support the SASL-IR capability? */
index eeedcff1773c3109a0226b1b2b344a62c45bc9bd..a8164c08403811dc552c1fda6f889ee49cd7c101 100644 (file)
@@ -62,6 +62,7 @@ struct imap_conn {
   int cmdid;              /* Last used command ID */
   char resptag[5];        /* Response tag to wait for */
   bool ssldone;           /* Is connect() over SSL done? */
+  bool tls_supported;     /* StartTLS capability supported by server */
   bool login_disabled;    /* LOGIN command explicitly disabled by server */
   bool ir_supported;      /* Initial response supported by server */
 };