aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/net/network-stream.el
diff options
context:
space:
mode:
authorRobert Pluim2019-01-24 14:35:30 +0100
committerRobert Pluim2019-11-05 09:32:51 +0100
commit91c732f687a61ba130acf38d5142bec6369ebd68 (patch)
tree2b64b552456aad27899a148940d3188b88f52743 /lisp/net/network-stream.el
parent3843711abd8d599206acbcc0aa97dae708285416 (diff)
downloademacs-91c732f687a61ba130acf38d5142bec6369ebd68.tar.gz
emacs-91c732f687a61ba130acf38d5142bec6369ebd68.zip
Always check for client-certificates
* lisp/net/network-stream.el (network-stream-use-client-certificates): New user option. (open-network-stream): If 'network-stream-use-client-certificates' is t, and the user hasn't specified :client-certificate, do certificate lookups via 'auth-source'. (network-stream-certificate): Only return key and certificate files that exist. * doc/lispref/processes.texi (Network): Document new client-certificate behavior. * etc/NEWS: Document 'network-stream-use-client-certificates'.
Diffstat (limited to 'lisp/net/network-stream.el')
-rw-r--r--lisp/net/network-stream.el26
1 files changed, 24 insertions, 2 deletions
diff --git a/lisp/net/network-stream.el b/lisp/net/network-stream.el
index 2b3292b71ba..4050c83eb0c 100644
--- a/lisp/net/network-stream.el
+++ b/lisp/net/network-stream.el
@@ -58,6 +58,21 @@
58(defvar starttls-gnutls-program) 58(defvar starttls-gnutls-program)
59(defvar starttls-program) 59(defvar starttls-program)
60 60
61(defcustom network-stream-use-client-certificates t
62 "Whether to use client certificates for network connections.
63
64When non-nil, `open-network-stream' will automatically look for
65matching client certificates (via 'auth-source') for a
66destination server, if it is called without a :client-certificate
67keyword.
68
69Set to nil to disable this lookup globally. To disable on a
70per-connection basis, specify ':client-certificate nil' when
71calling `open-network-stream'."
72 :group 'network
73 :type 'boolean
74 :version "27.1")
75
61;;;###autoload 76;;;###autoload
62(defun open-network-stream (name buffer host service &rest parameters) 77(defun open-network-stream (name buffer host service &rest parameters)
63 "Open a TCP connection to HOST, optionally with encryption. 78 "Open a TCP connection to HOST, optionally with encryption.
@@ -132,7 +147,9 @@ values:
132 element is the certificate file name itself, or t, which 147 element is the certificate file name itself, or t, which
133 means that `auth-source' will be queried for the key and the 148 means that `auth-source' will be queried for the key and the
134 certificate. This parameter will only be used when doing TLS 149 certificate. This parameter will only be used when doing TLS
135 or STARTTLS connections. 150 or STARTTLS connections. If :client-certificate is not
151 specified, behave as if it were t, customize
152 `network-stream-use-client-certificates' to change this.
136 153
137:use-starttls-if-possible is a boolean that says to do opportunistic 154:use-starttls-if-possible is a boolean that says to do opportunistic
138STARTTLS upgrades even if Emacs doesn't have built-in TLS functionality. 155STARTTLS upgrades even if Emacs doesn't have built-in TLS functionality.
@@ -181,6 +198,11 @@ gnutls-boot (as returned by `gnutls-boot-parameters')."
181 ((memq type '(tls ssl)) 'network-stream-open-tls) 198 ((memq type '(tls ssl)) 'network-stream-open-tls)
182 ((eq type 'shell) 'network-stream-open-shell) 199 ((eq type 'shell) 'network-stream-open-shell)
183 (t (error "Invalid connection type %s" type)))) 200 (t (error "Invalid connection type %s" type))))
201 (parameters
202 (if (and network-stream-use-client-certificates
203 (not (plist-member parameters :client-certificate)))
204 (plist-put parameters :client-certificate t)
205 parameters))
184 result) 206 result)
185 (unwind-protect 207 (unwind-protect
186 (setq result (funcall fun name work-buffer host service parameters)) 208 (setq result (funcall fun name work-buffer host service parameters))
@@ -209,7 +231,7 @@ gnutls-boot (as returned by `gnutls-boot-parameters')."
209 :port service))) 231 :port service)))
210 (key (plist-get auth-info :key)) 232 (key (plist-get auth-info :key))
211 (cert (plist-get auth-info :cert))) 233 (cert (plist-get auth-info :cert)))
212 (and key cert 234 (and key cert (file-readable-p key) (file-readable-p cert)
213 (list key cert))))))) 235 (list key cert)))))))
214 236
215;;;###autoload 237;;;###autoload