From 70233025bc5d0f151495408d9efb46bf5ece26c9 Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Sun, 28 Nov 2010 03:43:43 +0100 Subject: [PATCH] If STARTTLS failed, then just open a normal connection. --- lisp/ChangeLog | 2 ++ lisp/proto-stream.el | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2319ef781..96e6e46fa 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -6,6 +6,8 @@ that what we've checked for. (proto-stream-always-use-starttls): Only default to t if open-gnutls-stream exists. + (proto-stream-open-network): If STARTTLS failed, then just open a + normal connection. * nntp.el (nntp-open-connection): Report what the connection error is. diff --git a/lisp/proto-stream.el b/lisp/proto-stream.el index 6f4b019f3..c1acf4b9b 100644 --- a/lisp/proto-stream.el +++ b/lisp/proto-stream.el @@ -148,7 +148,16 @@ command to switch on STARTTLS otherwise." (proto-stream-command stream starttls-command eoc) (if (fboundp 'open-gnutls-stream) (gnutls-negotiate stream nil) - (starttls-negotiate stream)) + (unless (starttls-negotiate stream) + (delete-process stream) + (setq stream nil))) + (when (or (null stream) + (not (memq (process-status stream) + '(open run)))) + ;; It didn't successfully negotiate STARTTLS, so we reopen + ;; the connection. + (setq stream (open-network-stream name buffer host service)) + (proto-stream-get-response stream start eoc)) ;; Re-get the capabilities, since they may have changed ;; after switching to TLS. (list stream greeting -- 2.25.1