Mercurial > emacs
annotate lisp/gnus/starttls.el @ 82453:d04e217671f9
(ada-create-syntax-table): Move
set-syntax-table from here to ...
(ada-mode): ... here. Do not change global value of
comment-multi-line. Call new function
ada-initialize-syntax-table-properties and add new function
ada-handle-syntax-table-properties to font-lock-mode-hook.
(ada-deactivate-properties, ada-initialize-properties): Replace
by new functions ...
(ada-handle-syntax-table-properties)
(ada-initialize-syntax-table-properties)
(ada-set-syntax-table-properties): ... to set up syntax-table
properties uniformly, independently from whether font-lock-mode
is enabled or not. Handle read-only buffers and do not change
undo-list when setting syntax-table properties.
(ada-after-change-function): Use ada-set-syntax-table-properties.
author | Martin Rudalics <rudalics@gmx.at> |
---|---|
date | Sat, 18 Aug 2007 08:37:41 +0000 |
parents | 24202b793a08 |
children | 1cb31606209f f55f9811f5d7 |
rev | line source |
---|---|
34219 | 1 ;;; starttls.el --- STARTTLS functions |
2 | |
74548 | 3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, |
75347 | 4 ;; 2005, 2006, 2007 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 | |
78224
24202b793a08
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
75347
diff
changeset
|
15 ;; the Free Software Foundation; either version 3, or (at your option) |
34220 | 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 | |
67643
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
35 ;; This file now contains a combination of the two previous |
55783
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 |
67643
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
47 ;; The GNUTLS support requires GNUTLS 0.9.90 (released 2003-10-08) or |
55783
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 |
67643
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
61 ;; An example run yields the following output: |
55783
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'. |
67643
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
149 These apply when the `starttls' command is used, i.e. when |
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
150 `starttls-use-gnutls' is nil." |
55783
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'. |
67643
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
156 These apply when GNUTLS is used, i.e. when `starttls-use-gnutls' is non-nil. |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
157 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
158 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
|
159 '(\"--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
|
160 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
|
161 :version "22.1" |
34220 | 162 :type '(repeat string) |
34219 | 163 :group 'starttls) |
164 | |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
165 (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
|
166 "*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
|
167 :version "22.1" |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
168 :type 'boolean |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
169 :group 'starttls) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
170 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
171 (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
|
172 "*Regular expression indicating successful connection. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
173 The default is what GNUTLS's \"gnutls-cli\" outputs." |
67643
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
174 ;; GNUTLS cli.c:main() prints this string when it is starting to run |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
175 ;; 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
|
176 ;; 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
|
177 :version "22.1" |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
178 :type 'regexp |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
179 :group 'starttls) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
180 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
181 (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
|
182 "*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
|
183 The default is what GNUTLS's \"gnutls-cli\" outputs." |
67643
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
184 ;; GNUTLS cli.c:do_handshake() prints this string on failure. If the |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
185 ;; 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
|
186 :version "22.1" |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
187 :type 'regexp |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
188 :group 'starttls) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
189 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
190 (defcustom starttls-success "- Compression: " |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
191 "*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
|
192 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
|
193 ;; 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
|
194 ;; 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
|
195 ;; 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
|
196 ;; 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
|
197 :version "22.1" |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
198 :type 'regexp |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
199 :group 'starttls) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
200 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
201 (defun starttls-negotiate-gnutls (process) |
67643
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
202 "Negotiate TLS on PROCESS opened by `open-starttls-stream'. |
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
203 This should typically only be done once. It typically returns a |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
204 multi-line informational message with information about the |
67643
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
205 handshake, or nil on failure." |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
206 (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
|
207 (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
|
208 ;; 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
|
209 (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
|
210 (with-current-buffer buffer |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
211 (save-excursion |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
212 (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
|
213 (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
|
214 (while (and (processp process) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
215 (eq (process-status process) 'run) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
216 (save-excursion |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
217 (goto-char old-max) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
218 (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
|
219 starttls-success nil t)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
220 (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
|
221 starttls-failure nil t)))))) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
222 (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
|
223 (sit-for 0.1)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
224 (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
|
225 (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
|
226 (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
|
227 ;; 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
|
228 (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
|
229 info |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
230 (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
|
231 nil)))))) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
232 |
34219 | 233 (defun starttls-negotiate (process) |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
234 (if starttls-use-gnutls |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
235 (starttls-negotiate-gnutls process) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
236 (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
|
237 |
62960
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62943
diff
changeset
|
238 (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
|
239 (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
|
240 (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
|
241 '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
|
242 (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
|
243 '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
|
244 |
67643
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
245 (defun starttls-open-stream-gnutls (name buffer host port) |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
246 (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
|
247 (let* (done |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
248 (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
|
249 (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
|
250 (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
|
251 starttls-gnutls-program "-s" host |
67643
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
252 "-p" (if (integerp port) |
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
253 (int-to-string port) |
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
254 port) |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
255 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
|
256 (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
|
257 (while (and (processp process) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
258 (eq (process-status process) 'run) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
259 (save-excursion |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
260 (set-buffer buffer) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
261 (goto-char old-max) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
262 (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
|
263 starttls-connect nil t))))) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
264 (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
|
265 (sit-for 0.1)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
266 (if done |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
267 (with-current-buffer buffer |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
268 (delete-region old-max done)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
269 (delete-process process) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
270 (setq process nil)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
271 (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
|
272 host (if done "done" "failed")) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
273 process)) |
34219 | 274 |
67643
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
275 (defun starttls-open-stream (name buffer host port) |
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
276 "Open a TLS connection for a port to a host. |
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
277 Returns a subprocess object to represent the connection. |
34219 | 278 Input and output work as for subprocesses; `delete-process' closes it. |
67643
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
279 Args are NAME BUFFER HOST PORT. |
34219 | 280 NAME is name for process. It is modified if necessary to make it unique. |
281 BUFFER is the buffer (or `buffer-name') to associate with the process. | |
282 Process output goes at end of that buffer, unless you specify | |
283 an output stream or filter function to handle the output. | |
284 BUFFER may be also nil, meaning that this process is not associated | |
285 with any buffer | |
286 Third arg is name of the host to connect to, or its IP address. | |
67643
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
287 Fourth arg PORT is an integer specifying a port to connect to. |
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
288 If `starttls-use-gnutls' is nil, this may also be a service name, but |
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
289 GNUTLS requires a port number." |
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 |
67643
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
291 (starttls-open-stream-gnutls name buffer host port) |
55783
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 |
67643
1c477099d3ac
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-676
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
295 host (format "%s" port) |
55783
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 |