Reinstate the auto-upgrade from unencrypted to STARTTLS, if possible.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Thu, 30 Sep 2010 21:24:40 +0000 (23:24 +0200)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Thu, 30 Sep 2010 21:24:40 +0000 (23:24 +0200)
lisp/ChangeLog
lisp/nnimap.el

index ece6132..007a266 100644 (file)
@@ -1,3 +1,8 @@
+2010-09-30  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+       * nnimap.el (nnimap-open-connection): Reinstate the auto-upgrade from
+       unencrypted to STARTTLS, if possible.
+
 2010-09-30  Teemu Likonen  <tlikonen@iki.fi>  (tiny change)
 
        * message.el (message-ignored-supersedes-headers): Strip Injection-*
index ff589e6..4d26cdb 100644 (file)
@@ -350,6 +350,21 @@ textual parts.")
                    "CAPABILITY" (cdr (nnimap-command "CAPABILITY")))))
            (when nnimap-server-port
              (push (format "%s" nnimap-server-port) ports))
+           ;; If this is a STARTTLS-capable server, then sever the
+           ;; connection and start a STARTTLS connection instead.
+           (when (and (eq nnimap-stream 'network)
+                      (member "STARTTLS" (nnimap-capabilities nnimap-object)))
+             (let ((nnimap-stream 'starttls))
+               (let ((tls-process
+                      (nnimap-open-connection buffer)))
+                 ;; If the STARTTLS connection was successful, we
+                 ;; kill our first non-encrypted connection.  If it
+                 ;; wasn't successful, we just use our unencrypted
+                 ;; connection.
+                 (when (memq (process-status tls-process) '(open run))
+                   (delete-process (nnimap-process nnimap-object))
+                   (kill-buffer (current-buffer))
+                   (return tls-process)))))
            (unless (equal connection-result "PREAUTH")
              (if (not (setq credentials
                             (if (eq nnimap-authenticator 'anonymous)
@@ -381,7 +396,7 @@ textual parts.")
            (when nnimap-object
              (when (member "QRESYNC" (nnimap-capabilities nnimap-object))
                (nnimap-command "ENABLE QRESYNC"))
-             t)))))))
+             (nnimap-process nnimap-object))))))))
 
 (defun nnimap-extend-tls-programs ()
   (let ((programs tls-program)