Mercurial > emacs
annotate lisp/gnus/starttls.el @ 57591:98d755565607
(calc-emacs-type-19, calc-emacs-type-epoch, calc-emacs-type-gnu19):
Removed.
(calc-digit-map, calc-read-key-sequence, calc-read-key): Removed
check for old emacs versions.
author | Jay Belanger <jay.p.belanger@gmail.com> |
---|---|
date | Tue, 19 Oct 2004 14:36:47 +0000 |
parents | cbd20e241bd5 |
children | df80d19d7a2e 0fde48feb604 4c90ffeb71c5 |
rev | line source |
---|---|
34219 | 1 ;;; starttls.el --- STARTTLS functions |
2 | |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
3 ;; Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc. |
34219 | 4 |
5 ;; 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
|
6 ;; Author: Simon Josefsson <simon@josefsson.org> |
34219 | 7 ;; Created: 1999/11/20 |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
8 ;; Keywords: TLS, SSL, OpenSSL, GNUTLS, mail, news |
34219 | 9 |
34220 | 10 ;; This file is part of GNU Emacs. |
34219 | 11 |
34220 | 12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
13 ;; it under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
34219 | 16 |
34220 | 17 ;; GNU Emacs is distributed in the hope that it will be useful, |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
34219 | 21 |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
26 | |
27 ;;; Commentary: | |
28 | |
29 ;; This module defines some utility functions for STARTTLS profiles. | |
30 | |
31 ;; [RFC 2595] "Using TLS with IMAP, POP3 and ACAP" | |
32 ;; by Chris Newman <chris.newman@innosoft.com> (1999/06) | |
33 | |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
34 ;; 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
|
35 ;; 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
|
36 ;; 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
|
37 ;; 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
|
38 ;; "gnutls-cli" from GNUTLS. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
39 ;; |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
40 ;; 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
|
41 ;; "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
|
42 ;; `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
|
43 ;; 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
|
44 ;; 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
|
45 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
46 ;; 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
|
47 ;; 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
|
48 ;; 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
|
49 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
50 ;; 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
|
51 ;; |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
52 ;; (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
|
53 ;; "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
|
54 ;; (accept-process-output tmp 15) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
55 ;; (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
|
56 ;; (accept-process-output tmp 15) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
57 ;; (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
|
58 ;; (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
|
59 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
60 ;; 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
|
61 ;; |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
62 ;; 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
|
63 ;; 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
|
64 ;; 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
|
65 ;; 250-ENHANCEDSTATUSCODES |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
66 ;; 250-PIPELINING |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
67 ;; 250-EXPN |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
68 ;; 250-VERB |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
69 ;; 250-8BITMIME |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
70 ;; 250-SIZE |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
71 ;; 250-DSN |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
72 ;; 250-ETRN |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
73 ;; 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
|
74 ;; 250-DELIVERBY |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
75 ;; 250 HELP |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
76 ;; nil |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
77 ;; |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
78 ;; With the message buffer containing: |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
79 ;; |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
80 ;; STARTTLS output: |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
81 ;; *** Starting TLS handshake |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
82 ;; - Server's trusted authorities: |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
83 ;; [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
|
84 ;; - Certificate type: X.509 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
85 ;; - 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
|
86 ;; |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
87 ;; - Certificate[0] info: |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
88 ;; # 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
|
89 ;; # 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
|
90 ;; # 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
|
91 ;; # serial number: 04 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
92 ;; # 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
|
93 ;; # version: #1 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
94 ;; # public key algorithm: RSA |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
95 ;; # Modulus: 1024 bits |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
96 ;; # 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
|
97 ;; # 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
|
98 ;; |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
99 ;; - Certificate[1] info: |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
100 ;; # 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
|
101 ;; # 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
|
102 ;; # serial number: 00 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
103 ;; # 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
|
104 ;; # version: #3 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
105 ;; # public key algorithm: RSA |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
106 ;; # Modulus: 1024 bits |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
107 ;; # 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
|
108 ;; # 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
|
109 ;; |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
110 ;; - 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
|
111 ;; - 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
|
112 ;; - Version: TLS 1.0 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
113 ;; - Key Exchange: RSA |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
114 ;; - Cipher: ARCFOUR 128 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
115 ;; - MAC: SHA |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
116 ;; - Compression: NULL |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
117 |
34219 | 118 ;;; Code: |
119 | |
120 (defgroup starttls nil | |
121 "Support for `Transport Layer Security' protocol." | |
34220 | 122 :version "21.1" |
123 :group 'mail) | |
34219 | 124 |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
125 (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
|
126 "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
|
127 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
|
128 `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
|
129 :type 'string |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
130 :group 'starttls) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
131 |
34219 | 132 (defcustom starttls-program "starttls" |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
133 "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
|
134 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
|
135 i.e. when `starttls-use-gnutls' is nil." |
34220 | 136 :type 'string |
34219 | 137 :group 'starttls) |
138 | |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
139 (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
|
140 "*Whether to use GNUTLS instead of the `starttls' command." |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
141 :type 'boolean |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
142 :group 'starttls) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
143 |
34219 | 144 (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
|
145 "Extra arguments to `starttls-program'. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
146 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
|
147 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
|
148 :type '(repeat string) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
149 :group 'starttls) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
150 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
151 (defcustom starttls-extra-arguments nil |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
152 "Extra arguments to `starttls-program'. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
153 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
|
154 `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
|
155 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
156 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
|
157 '(\"--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
|
158 find out which parameters are available." |
34220 | 159 :type '(repeat string) |
34219 | 160 :group 'starttls) |
161 | |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
162 (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
|
163 "*Value for `process-connection-type' to use when starting STARTTLS process." |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
164 :type 'boolean |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
165 :group 'starttls) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
166 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
167 (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
|
168 "*Regular expression indicating successful connection. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
169 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
|
170 ;; 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
|
171 ;; 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
|
172 ;; itself, is modified, this must be updated. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
173 :type 'regexp |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
174 :group 'starttls) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
175 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
176 (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
|
177 "*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
|
178 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
|
179 ;; 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
|
180 ;; logic, or the string itself, is modified, this must be updated. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
181 :type 'regexp |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
182 :group 'starttls) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
183 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
184 (defcustom starttls-success "- Compression: " |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
185 "*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
|
186 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
|
187 ;; 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
|
188 ;; 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
|
189 ;; 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
|
190 ;; must be updated. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
191 :type 'regexp |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
192 :group 'starttls) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
193 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
194 (defun starttls-negotiate-gnutls (process) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
195 "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
|
196 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
|
197 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
|
198 handshake, or NIL on failure." |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
199 (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
|
200 (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
|
201 ;; 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
|
202 (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
|
203 (with-current-buffer buffer |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
204 (save-excursion |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
205 (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
|
206 (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
|
207 (while (and (processp process) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
208 (eq (process-status process) 'run) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
209 (save-excursion |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
210 (goto-char old-max) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
211 (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
|
212 starttls-success nil t)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
213 (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
|
214 starttls-failure nil t)))))) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
215 (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
|
216 (sit-for 0.1)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
217 (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
|
218 (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
|
219 (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
|
220 ;; 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
|
221 (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
|
222 info |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
223 (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
|
224 nil)))))) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
225 |
34219 | 226 (defun starttls-negotiate (process) |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
227 (if starttls-use-gnutls |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
228 (starttls-negotiate-gnutls process) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
229 (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
|
230 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
231 (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
|
232 (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
|
233 (let* (done |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
234 (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
|
235 (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
|
236 (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
|
237 starttls-gnutls-program "-s" host |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
238 "-p" (if (integerp service) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
239 (int-to-string service) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
240 service) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
241 starttls-extra-arguments))) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
242 (process-kill-without-query process) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
243 (while (and (processp process) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
244 (eq (process-status process) 'run) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
245 (save-excursion |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
246 (set-buffer buffer) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
247 (goto-char old-max) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
248 (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
|
249 starttls-connect nil t))))) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
250 (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
|
251 (sit-for 0.1)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
252 (if done |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
253 (with-current-buffer buffer |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
254 (delete-region old-max done)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
255 (delete-process process) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
256 (setq process nil)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
257 (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
|
258 host (if done "done" "failed")) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
259 process)) |
34219 | 260 |
261 (defun starttls-open-stream (name buffer host service) | |
262 "Open a TLS connection for a service to a host. | |
263 Returns a subprocess-object to represent the connection. | |
264 Input and output work as for subprocesses; `delete-process' closes it. | |
265 Args are NAME BUFFER HOST SERVICE. | |
266 NAME is name for process. It is modified if necessary to make it unique. | |
267 BUFFER is the buffer (or `buffer-name') to associate with the process. | |
268 Process output goes at end of that buffer, unless you specify | |
269 an output stream or filter function to handle the output. | |
270 BUFFER may be also nil, meaning that this process is not associated | |
271 with any buffer | |
272 Third arg is name of the host to connect to, or its IP address. | |
273 Fourth arg SERVICE is name of the service desired, or an integer | |
274 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
|
275 (if starttls-use-gnutls |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
276 (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
|
277 (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
|
278 (process (apply #'start-process |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
279 name buffer starttls-program |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
280 host (format "%s" service) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
281 starttls-extra-args))) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
282 (process-kill-without-query process) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
283 process))) |
34219 | 284 |
285 (provide 'starttls) | |
286 | |
52401 | 287 ;;; arch-tag: 648b3bd8-63bd-47f5-904c-7c819aea2297 |
34219 | 288 ;;; starttls.el ends here |