summaryrefslogtreecommitdiff
path: root/lisp/net/network-stream.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/net/network-stream.el')
-rw-r--r--lisp/net/network-stream.el12
1 files changed, 10 insertions, 2 deletions
diff --git a/lisp/net/network-stream.el b/lisp/net/network-stream.el
index 038794e117..bb09d8945c 100644
--- a/lisp/net/network-stream.el
+++ b/lisp/net/network-stream.el
@@ -263,8 +263,16 @@ functionality.
;; The server said it was OK to begin STARTTLS negotiations.
(if builtin-starttls
(let ((cert (network-stream-certificate host service parameters)))
- (gnutls-negotiate :process stream :hostname host
- :keylist (and cert (list cert))))
+ (condition-case nil
+ (gnutls-negotiate :process stream :hostname host
+ :keylist (and cert (list cert)))
+ ;; If we get a gnutls-specific error (for instance if
+ ;; the certificate the server gives us is completely
+ ;; syntactically invalid), then close the connection
+ ;; and possibly (further down) try to create a
+ ;; non-encrypted connection.
+ (gnutls-error
+ (delete-process stream))))
(unless (starttls-negotiate stream)
(delete-process stream)))
(if (memq (process-status stream) '(open run))