1 ;;; starttls.el --- STARTTLS functions
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Author: Daiki Ueno <ueno@unixuser.org>
7 ;; Author: Simon Josefsson <simon@josefsson.org>
9 ;; Keywords: TLS, SSL, OpenSSL, GNUTLS, mail, news
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation, either version 3 of the License, or
16 ;; (at your option) any later version.
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.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
28 ;; This module defines some utility functions for STARTTLS profiles.
30 ;; [RFC 2595] "Using TLS with IMAP, POP3 and ACAP"
31 ;; by Chris Newman <chris.newman@innosoft.com> (1999/06)
33 ;; This file now contains a combination of the two previous
34 ;; implementations both called "starttls.el". The first one is Daiki
35 ;; Ueno's starttls.el which uses his own "starttls" command line tool,
36 ;; and the second one is Simon Josefsson's starttls.el which uses
37 ;; "gnutls-cli" from GNUTLS.
39 ;; If "starttls" is available, it is prefered by the code over
40 ;; "gnutls-cli", for backwards compatibility. Use
41 ;; `starttls-use-gnutls' to toggle between implementations if you have
42 ;; both tools installed. It is recommended to use GNUTLS, though, as
43 ;; it performs more verification of the certificates.
45 ;; The GNUTLS support requires GNUTLS 0.9.90 (released 2003-10-08) or
46 ;; later, from <http://www.gnu.org/software/gnutls/>, or "starttls"
47 ;; from <ftp://ftp.opaopa.org/pub/elisp/>.
49 ;; Usage is similar to `open-network-stream'. For example:
51 ;; (when (setq tmp (starttls-open-stream
52 ;; "test" (current-buffer) "yxa.extundo.com" 25))
53 ;; (accept-process-output tmp 15)
54 ;; (process-send-string tmp "STARTTLS\n")
55 ;; (accept-process-output tmp 15)
56 ;; (message "STARTTLS output:\n%s" (starttls-negotiate tmp))
57 ;; (process-send-string tmp "EHLO foo\n"))
59 ;; An example run yields the following output:
61 ;; 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]
62 ;; 220 2.0.0 Ready to start TLS
63 ;; 250-yxa.extundo.com Hello c494102a.s-bi.bostream.se [217.215.27.65], pleased to meet you
64 ;; 250-ENHANCEDSTATUSCODES
72 ;; 250-AUTH DIGEST-MD5 CRAM-MD5 PLAIN LOGIN
77 ;; With the message buffer containing:
80 ;; *** Starting TLS handshake
81 ;; - Server's trusted authorities:
82 ;; [0]: C=SE,ST=Stockholm,L=Stockholm,O=YXA,OU=CA,CN=yxa.extundo.com,EMAIL=staff@yxa.extundo.com
83 ;; - Certificate type: X.509
84 ;; - Got a certificate list of 2 certificates.
86 ;; - Certificate[0] info:
87 ;; # The hostname in the certificate matches 'yxa.extundo.com'.
88 ;; # valid since: Wed May 26 12:16:00 CEST 2004
89 ;; # expires at: Wed Jul 26 12:16:00 CEST 2023