From eb6cd2ccfae1264c5d1c63f3d52f0bf2f5571cba Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Sun, 10 Oct 2010 20:49:49 +0200 Subject: [PATCH] (nnimap-open-connection): Use gnutls STARTTLS, if available. --- lisp/ChangeLog | 3 +++ lisp/nnimap.el | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4674dd014..06f683c1e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2010-10-10 Lars Magne Ingebrigtsen + * nnimap.el (nnimap-open-connection): Use gnutls STARTTLS, if + available. + * auth-source.el (auth-source-create): Use (user-login-name) for the user name default. diff --git a/lisp/nnimap.el b/lisp/nnimap.el index aaa642017..99aee4cdd 100644 --- a/lisp/nnimap.el +++ b/lisp/nnimap.el @@ -295,7 +295,9 @@ textual parts.") (port nil) (ports (cond - ((eq nnimap-stream 'network) + ((or (eq nnimap-stream 'network) + (and (eq nnimap-stream 'starttls) + (fboundp 'open-gnutls-stream))) (open-network-stream "*nnimap*" (current-buffer) nnimap-address (setq port @@ -357,8 +359,16 @@ textual parts.") (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))) + (cond + ((and (or (and (eq nnimap-stream 'network) + (member "STARTTLS" + (nnimap-capabilities nnimap-object))) + (eq nnimap-stream 'starttls)) + (fboundp 'open-gnutls-stream)) + (nnimap-command "STARTTLS") + (gnutls-negotiate (nnimap-process nnimap-object) nil)) + ((and (eq nnimap-stream 'network) + (member "STARTTLS" (nnimap-capabilities nnimap-object))) (let ((nnimap-stream 'starttls)) (let ((tls-process (nnimap-open-connection buffer))) @@ -369,7 +379,7 @@ textual parts.") (when (memq (process-status tls-process) '(open run)) (delete-process (nnimap-process nnimap-object)) (kill-buffer (current-buffer)) - (return tls-process))))) + (return tls-process)))))) (unless (equal connection-result "PREAUTH") (if (not (setq credentials (if (eq nnimap-authenticator 'anonymous) -- 2.25.1