Mercurial > emacs
annotate lisp/gnus/starttls.el @ 64295:f2e16ba201e0
(define-minor-mode): Do not override explicitly specified :initialize keyword.
author | Luc Teirlinck <teirllm@auburn.edu> |
---|---|
date | Thu, 14 Jul 2005 00:56:13 +0000 |
parents | 18a818a2ee7c |
children | fafd692d1e40 f9a65d7ebd29 |
rev | line source |
---|---|
34219 | 1 ;;; starttls.el --- STARTTLS functions |
2 | |
62943
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
59996
diff
changeset
|
3 ;; Copyright (C) 1999, 2000, 2003, 2004, 2005 |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
59996
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
34219 | 5 |
6 ;; Author: Daiki Ueno <ueno@unixuser.org> | |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
7 ;; Author: Simon Josefsson <simon@josefsson.org> |
34219 | 8 ;; Created: 1999/11/20 |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
9 ;; Keywords: TLS, SSL, OpenSSL, GNUTLS, mail, news |
34219 | 10 |
34220 | 11 ;; This file is part of GNU Emacs. |
34219 | 12 |
34220 | 13 ;; GNU Emacs is free software; you can redistribute it and/or modify |
14 ;; it under the terms of the GNU General Public License as published by | |
15 ;; the Free Software Foundation; either version 2, or (at your option) | |
16 ;; any later version. | |
34219 | 17 |
34220 | 18 ;; GNU Emacs is distributed in the hope that it will be useful, |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
34219 | 22 |
23 ;; You should have received a copy of the GNU General Public License | |
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64085 | 25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
26 ;; Boston, MA 02110-1301, USA. | |
34219 | 27 |
28 ;;; Commentary: | |
29 | |
30 ;; This module defines some utility functions for STARTTLS profiles. | |
31 | |
32 ;; [RFC 2595] "Using TLS with IMAP, POP3 and ACAP" | |
33 ;; by Chris Newman <chris.newman@innosoft.com> (1999/06) | |
34 | |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
35 ;; This file now contain a combination of the two previous |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
36 ;; implementations both called "starttls.el". The first one is Daiki |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
37 ;; Ueno's starttls.el which uses his own "starttls" command line tool, |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
38 ;; and the second one is Simon Josefsson's starttls.el which uses |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
39 ;; "gnutls-cli" from GNUTLS. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
40 ;; |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
41 ;; If "starttls" is available, it is prefered by the code over |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
42 ;; "gnutls-cli", for backwards compatibility. Use |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
43 ;; `starttls-use-gnutls' to toggle between implementations if you have |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
44 ;; both tools installed. It is recommended to use GNUTLS, though, as |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
45 ;; it performs more verification of the certificates. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
46 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
47 ;; The GNUTLS support require GNUTLS 0.9.90 (released 2003-10-08) or |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
48 ;; later, from <http://www.gnu.org/software/gnutls/>, or "starttls" |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
49 ;; from <ftp://ftp.opaopa.org/pub/elisp/>. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
50 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
51 ;; Usage is similar to `open-network-stream'. For example: |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
52 ;; |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
53 ;; (when (setq tmp (starttls-open-stream |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
54 ;; "test" (current-buffer) "yxa.extundo.com" 25)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
55 ;; (accept-process-output tmp 15) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
56 ;; (process-send-string tmp "STARTTLS\n") |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
57 ;; (accept-process-output tmp 15) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
58 ;; (message "STARTTLS output:\n%s" (starttls-negotiate tmp)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
59 ;; (process-send-string tmp "EHLO foo\n")) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
60 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
61 ;; An example run yield the following output: |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
62 ;; |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
63 ;; 220 yxa.extundo.com ESMTP Sendmail 8.12.11/8.12.11/Debian-3; Wed, 26 May 2004 19:12:29 +0200; (No UCE/UBE) logging access from: c494102a.s-bi.bostream.se(OK)-c494102a.s-bi.bostream.se [217.215.27.65] |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
64 ;; 220 2.0.0 Ready to start TLS |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
65 ;; 250-yxa.extundo.com Hello c494102a.s-bi.bostream.se [217.215.27.65], pleased to meet you |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
66 ;; 250-ENHANCEDSTATUSCODES |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
67 ;; 250-PIPELINING |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
68 ;; 250-EXPN |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
69 ;; 250-VERB |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
70 ;; 250-8BITMIME |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
71 ;; 250-SIZE |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
72 ;; 250-DSN |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
73 ;; 250-ETRN |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
74 ;; 250-AUTH DIGEST-MD5 CRAM-MD5 PLAIN LOGIN |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
75 ;; 250-DELIVERBY |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
76 ;; 250 HELP |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
77 ;; nil |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
78 ;; |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
79 ;; With the message buffer containing: |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
80 ;; |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
81 ;; STARTTLS output: |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
82 ;; *** Starting TLS handshake |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
83 ;; - Server's trusted authorities: |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
84 ;; [0]: C=SE,ST=Stockholm,L=Stockholm,O=YXA,OU=CA,CN=yxa.extundo.com,EMAIL=staff@yxa.extundo.com |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
85 ;; - Certificate type: X.509 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
86 ;; - Got a certificate list of 2 certificates. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
87 ;; |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
88 ;; - Certificate[0] info: |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
89 ;; # The hostname in the certificate matches 'yxa.extundo.com'. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
90 ;; # valid since: Wed May 26 12:16:00 CEST 2004 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
91 ;; # expires at: Wed Jul 26 12:16:00 CEST 2023 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
92 ;; # serial number: 04 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
93 ;; # fingerprint: 7c 04 4b c1 fa 26 9b 5d 90 22 52 3c 65 3d 85 3a |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
94 ;; # version: #1 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
95 ;; # public key algorithm: RSA |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
96 ;; # Modulus: 1024 bits |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
97 ;; # Subject's DN: C=SE,ST=Stockholm,L=Stockholm,O=YXA,OU=Mail server,CN=yxa.extundo.com,EMAIL=staff@yxa.extundo.com |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
98 ;; # Issuer's DN: C=SE,ST=Stockholm,L=Stockholm,O=YXA,OU=CA,CN=yxa.extundo.com,EMAIL=staff@yxa.extundo.com |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
99 ;; |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
100 ;; - Certificate[1] info: |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
101 ;; # valid since: Sun May 23 11:35:00 CEST 2004 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
102 ;; # expires at: Sun Jul 23 11:35:00 CEST 2023 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
103 ;; # serial number: 00 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
104 ;; # fingerprint: fc 76 d8 63 1a c9 0b 3b fa 40 fe ed 47 7a 58 ae |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
105 ;; # version: #3 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
106 ;; # public key algorithm: RSA |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
107 ;; # Modulus: 1024 bits |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
108 ;; # Subject's DN: C=SE,ST=Stockholm,L=Stockholm,O=YXA,OU=CA,CN=yxa.extundo.com,EMAIL=staff@yxa.extundo.com |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
109 ;; # Issuer's DN: C=SE,ST=Stockholm,L=Stockholm,O=YXA,OU=CA,CN=yxa.extundo.com,EMAIL=staff@yxa.extundo.com |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
110 ;; |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
111 ;; - Peer's certificate issuer is unknown |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
112 ;; - Peer's certificate is NOT trusted |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
113 ;; - Version: TLS 1.0 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
114 ;; - Key Exchange: RSA |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
115 ;; - Cipher: ARCFOUR 128 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
116 ;; - MAC: SHA |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
117 ;; - Compression: NULL |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
118 |
34219 | 119 ;;; Code: |
120 | |
121 (defgroup starttls nil | |
122 "Support for `Transport Layer Security' protocol." | |
34220 | 123 :version "21.1" |
124 :group 'mail) | |
34219 | 125 |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
126 (defcustom starttls-gnutls-program "gnutls-cli" |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
127 "Name of GNUTLS command line tool. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
128 This program is used when GNUTLS is used, i.e. when |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
129 `starttls-use-gnutls' is non-nil." |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
57856
diff
changeset
|
130 :version "22.1" |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
131 :type 'string |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
132 :group 'starttls) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
133 |
34219 | 134 (defcustom starttls-program "starttls" |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
135 "The program to run in a subprocess to open an TLSv1 connection. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
136 This program is used when the `starttls' command is used, |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
137 i.e. when `starttls-use-gnutls' is nil." |
34220 | 138 :type 'string |
34219 | 139 :group 'starttls) |
140 | |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
141 (defcustom starttls-use-gnutls (not (executable-find starttls-program)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
142 "*Whether to use GNUTLS instead of the `starttls' command." |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
57856
diff
changeset
|
143 :version "22.1" |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
144 :type 'boolean |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
145 :group 'starttls) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
146 |
34219 | 147 (defcustom starttls-extra-args nil |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
148 "Extra arguments to `starttls-program'. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
149 This program is used when the `starttls' command is used, |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
150 i.e. when `starttls-use-gnutls' is nil." |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
151 :type '(repeat string) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
152 :group 'starttls) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
153 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
154 (defcustom starttls-extra-arguments nil |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
155 "Extra arguments to `starttls-program'. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
156 This program is used when GNUTLS is used, i.e. when |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
157 `starttls-use-gnutls' is non-nil. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
158 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
159 For example, non-TLS compliant servers may require |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
160 '(\"--protocols\" \"ssl3\"). Invoke \"gnutls-cli --help\" to |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
161 find out which parameters are available." |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
57856
diff
changeset
|
162 :version "22.1" |
34220 | 163 :type '(repeat string) |
34219 | 164 :group 'starttls) |
165 | |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
166 (defcustom starttls-process-connection-type nil |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
167 "*Value for `process-connection-type' to use when starting STARTTLS process." |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
57856
diff
changeset
|
168 :version "22.1" |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
169 :type 'boolean |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
170 :group 'starttls) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
171 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
172 (defcustom starttls-connect "- Simple Client Mode:\n\n" |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
173 "*Regular expression indicating successful connection. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
174 The default is what GNUTLS's \"gnutls-cli\" outputs." |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
175 ;; GNUTLS cli.c:main() print this string when it is starting to run |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
176 ;; in the application read/write phase. If the logic, or the string |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
177 ;; itself, is modified, this must be updated. |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
57856
diff
changeset
|
178 :version "22.1" |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
179 :type 'regexp |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
180 :group 'starttls) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
181 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
182 (defcustom starttls-failure "\\*\\*\\* Handshake has failed" |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
183 "*Regular expression indicating failed TLS handshake. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
184 The default is what GNUTLS's \"gnutls-cli\" outputs." |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
185 ;; GNUTLS cli.c:do_handshake() print this string on failure. If the |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
186 ;; logic, or the string itself, is modified, this must be updated. |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
57856
diff
changeset
|
187 :version "22.1" |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
188 :type 'regexp |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
189 :group 'starttls) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
190 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
191 (defcustom starttls-success "- Compression: " |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
192 "*Regular expression indicating completed TLS handshakes. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
193 The default is what GNUTLS's \"gnutls-cli\" outputs." |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
194 ;; GNUTLS cli.c:do_handshake() calls, on success, |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
195 ;; common.c:print_info(), that unconditionally print this string |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
196 ;; last. If that logic, or the string itself, is modified, this |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
197 ;; must be updated. |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
57856
diff
changeset
|
198 :version "22.1" |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
199 :type 'regexp |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
200 :group 'starttls) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
201 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
202 (defun starttls-negotiate-gnutls (process) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
203 "Negotiate TLS on process opened by `open-starttls-stream'. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
204 This should typically only be done once. It typically return a |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
205 multi-line informational message with information about the |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
206 handshake, or NIL on failure." |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
207 (let (buffer info old-max done-ok done-bad) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
208 (if (null (setq buffer (process-buffer process))) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
209 ;; XXX How to remove/extract the TLS negotiation junk? |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
210 (signal-process (process-id process) 'SIGALRM) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
211 (with-current-buffer buffer |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
212 (save-excursion |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
213 (setq old-max (goto-char (point-max))) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
214 (signal-process (process-id process) 'SIGALRM) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
215 (while (and (processp process) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
216 (eq (process-status process) 'run) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
217 (save-excursion |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
218 (goto-char old-max) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
219 (not (or (setq done-ok (re-search-forward |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
220 starttls-success nil t)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
221 (setq done-bad (re-search-forward |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
222 starttls-failure nil t)))))) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
223 (accept-process-output process 1 100) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
224 (sit-for 0.1)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
225 (setq info (buffer-substring-no-properties old-max (point-max))) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
226 (delete-region old-max (point-max)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
227 (if (or (and done-ok (not done-bad)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
228 ;; Prevent mitm that fake success msg after failure msg. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
229 (and done-ok done-bad (< done-ok done-bad))) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
230 info |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
231 (message "STARTTLS negotiation failed: %s" info) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
232 nil)))))) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
233 |
34219 | 234 (defun starttls-negotiate (process) |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
235 (if starttls-use-gnutls |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
236 (starttls-negotiate-gnutls process) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
237 (signal-process (process-id process) 'SIGALRM))) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
238 |
62960
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62943
diff
changeset
|
239 (eval-and-compile |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62943
diff
changeset
|
240 (if (fboundp 'set-process-query-on-exit-flag) |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62943
diff
changeset
|
241 (defalias 'starttls-set-process-query-on-exit-flag |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62943
diff
changeset
|
242 'set-process-query-on-exit-flag) |
62943
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
59996
diff
changeset
|
243 (defalias 'starttls-set-process-query-on-exit-flag |
62960
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62943
diff
changeset
|
244 'process-kill-without-query))) |
62943
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
59996
diff
changeset
|
245 |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
246 (defun starttls-open-stream-gnutls (name buffer host service) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
247 (message "Opening STARTTLS connection to `%s'..." host) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
248 (let* (done |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
249 (old-max (with-current-buffer buffer (point-max))) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
250 (process-connection-type starttls-process-connection-type) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
251 (process (apply #'start-process name buffer |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
252 starttls-gnutls-program "-s" host |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
253 "-p" (if (integerp service) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
254 (int-to-string service) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
255 service) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
256 starttls-extra-arguments))) |
62943
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
59996
diff
changeset
|
257 (starttls-set-process-query-on-exit-flag process nil) |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
258 (while (and (processp process) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
259 (eq (process-status process) 'run) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
260 (save-excursion |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
261 (set-buffer buffer) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
262 (goto-char old-max) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
263 (not (setq done (re-search-forward |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
264 starttls-connect nil t))))) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
265 (accept-process-output process 0 100) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
266 (sit-for 0.1)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
267 (if done |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
268 (with-current-buffer buffer |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
269 (delete-region old-max done)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
270 (delete-process process) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
271 (setq process nil)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
272 (message "Opening STARTTLS connection to `%s'...%s" |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
273 host (if done "done" "failed")) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
274 process)) |
34219 | 275 |
276 (defun starttls-open-stream (name buffer host service) | |
277 "Open a TLS connection for a service to a host. | |
278 Returns a subprocess-object to represent the connection. | |
279 Input and output work as for subprocesses; `delete-process' closes it. | |
280 Args are NAME BUFFER HOST SERVICE. | |
281 NAME is name for process. It is modified if necessary to make it unique. | |
282 BUFFER is the buffer (or `buffer-name') to associate with the process. | |
283 Process output goes at end of that buffer, unless you specify | |
284 an output stream or filter function to handle the output. | |
285 BUFFER may be also nil, meaning that this process is not associated | |
286 with any buffer | |
287 Third arg is name of the host to connect to, or its IP address. | |
288 Fourth arg SERVICE is name of the service desired, or an integer | |
289 specifying a port number to connect to." | |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
290 (if starttls-use-gnutls |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
291 (starttls-open-stream-gnutls name buffer host service) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
292 (let* ((process-connection-type starttls-process-connection-type) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
293 (process (apply #'start-process |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
294 name buffer starttls-program |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
295 host (format "%s" service) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
296 starttls-extra-args))) |
62943
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
59996
diff
changeset
|
297 (starttls-set-process-query-on-exit-flag process nil) |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
298 process))) |
34219 | 299 |
300 (provide 'starttls) | |
301 | |
52401 | 302 ;;; arch-tag: 648b3bd8-63bd-47f5-904c-7c819aea2297 |
34219 | 303 ;;; starttls.el ends here |