Mercurial > emacs
annotate lisp/gnus/starttls.el @ 61906:1210b12b4089
(Defining Minor Modes): Fix previous change.
(Font Lock Mode): Simplify.
(Font Lock Basics): Say that font-lock-defaults is buffer-local
when set and that some parts are optional. Add cross references.
(Search-based Fontification): Say how to specify font-lock-keywords.
Add cross references. Add font-lock-multiline to index. Move
font-lock-keywords-case-fold-search here from node "Other Font
Lock Variables". Document font-lock-add-keywords and
font-lock-remove-keywords
(Other Font Lock Variables): Move font-lock-keywords-only,
font-lock-syntax-table, font-lock-beginning-of-syntax-function,
and font-lock-syntactic-face-function to node "Syntactic Font
Lock". Move font-lock-keywords-case-fold-search to node
"Search-based Fontification". Document font-lock-inhibit-thing-lock
and font-lock-{,un}fontify-{buffer,region}-function.
(Precalculated Fontification): Remove reference to deleted variable
font-lock-core-only.
(Faces for Font Lock): Add font-lock-comment-delimiter-face.
(Syntactic Font Lock): Add intro. Move font-lock-keywords-only,
font-lock-syntax-table, font-lock-beginning-of-syntax-function,
and font-lock-syntactic-face-function here from node "Other Font
Lock Variables". Move font-lock-syntactic-keywords to "Setting
Syntax Properties". Add cross references.
(Setting Syntax Properties): New node. Move
font-lock-syntactic-keywords here from "Syntactic Font Lock".
author | Lute Kamstra <lute@gnu.org> |
---|---|
date | Thu, 28 Apr 2005 11:32:54 +0000 |
parents | aac0a33f5772 |
children | 11d53dd5abd9 3ebd9bdb4fe5 |
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." |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
57856
diff
changeset
|
129 :version "22.1" |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
130 :type 'string |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
131 :group 'starttls) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
132 |
34219 | 133 (defcustom starttls-program "starttls" |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
134 "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
|
135 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
|
136 i.e. when `starttls-use-gnutls' is nil." |
34220 | 137 :type 'string |
34219 | 138 :group 'starttls) |
139 | |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
140 (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
|
141 "*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
|
142 :version "22.1" |
55783
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
143 :type 'boolean |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
144 :group 'starttls) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
145 |
34219 | 146 (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
|
147 "Extra arguments to `starttls-program'. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
148 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
|
149 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
|
150 :type '(repeat string) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
151 :group 'starttls) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
152 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
153 (defcustom starttls-extra-arguments nil |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
154 "Extra arguments to `starttls-program'. |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
155 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
|
156 `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
|
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." |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
174 ;; 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
|
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." |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
184 ;; 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
|
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) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
202 "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
|
203 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
|
204 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
|
205 handshake, or NIL on failure." |
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 |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
238 (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
|
239 (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
|
240 (let* (done |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
241 (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
|
242 (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
|
243 (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
|
244 starttls-gnutls-program "-s" host |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
245 "-p" (if (integerp service) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
246 (int-to-string service) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
247 service) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
248 starttls-extra-arguments))) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
249 (process-kill-without-query process) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
250 (while (and (processp process) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
251 (eq (process-status process) 'run) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
252 (save-excursion |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
253 (set-buffer buffer) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
254 (goto-char old-max) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
255 (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
|
256 starttls-connect nil t))))) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
257 (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
|
258 (sit-for 0.1)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
259 (if done |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
260 (with-current-buffer buffer |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
261 (delete-region old-max done)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
262 (delete-process process) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
263 (setq process nil)) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
264 (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
|
265 host (if done "done" "failed")) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
266 process)) |
34219 | 267 |
268 (defun starttls-open-stream (name buffer host service) | |
269 "Open a TLS connection for a service to a host. | |
270 Returns a subprocess-object to represent the connection. | |
271 Input and output work as for subprocesses; `delete-process' closes it. | |
272 Args are NAME BUFFER HOST SERVICE. | |
273 NAME is name for process. It is modified if necessary to make it unique. | |
274 BUFFER is the buffer (or `buffer-name') to associate with the process. | |
275 Process output goes at end of that buffer, unless you specify | |
276 an output stream or filter function to handle the output. | |
277 BUFFER may be also nil, meaning that this process is not associated | |
278 with any buffer | |
279 Third arg is name of the host to connect to, or its IP address. | |
280 Fourth arg SERVICE is name of the service desired, or an integer | |
281 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
|
282 (if starttls-use-gnutls |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
283 (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
|
284 (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
|
285 (process (apply #'start-process |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
286 name buffer starttls-program |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
287 host (format "%s" service) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
288 starttls-extra-args))) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
289 (process-kill-without-query process) |
cbd20e241bd5
starttls.el: Merge with my GNUTLS based starttls.el.
Simon Josefsson <jas@extundo.com>
parents:
52401
diff
changeset
|
290 process))) |
34219 | 291 |
292 (provide 'starttls) | |
293 | |
52401 | 294 ;;; arch-tag: 648b3bd8-63bd-47f5-904c-7c819aea2297 |
34219 | 295 ;;; starttls.el ends here |