| 1 | ;;; starttls.el --- STARTTLS functions |
| 2 | |
| 3 | ;; Copyright (C) 1999, 2000 Free Software Foundation, Inc. |
| 4 | |
| 5 | ;; Author: Daiki Ueno <ueno@unixuser.org> |
| 6 | ;; Created: 1999/11/20 |
| 7 | ;; Keywords: TLS, SSL, OpenSSL, mail, news |
| 8 | |
| 9 | ;; This file is part of GNU Emacs. |
| 10 | |
| 11 | ;; GNU Emacs is free software; you can redistribute it and/or modify |
| 12 | ;; it under the terms of the GNU General Public License as published by |
| 13 | ;; the Free Software Foundation; either version 2, or (at your option) |
| 14 | ;; any later version. |
| 15 | |
| 16 | ;; GNU Emacs is distributed in the hope that it will be useful, |
| 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | ;; GNU General Public License for more details. |
| 20 | |
| 21 | ;; You should have received a copy of the GNU General Public License |
| 22 | ;; along with GNU Emacs; see the file COPYING. If not, write to the |
| 23 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 24 | ;; Boston, MA 02111-1307, USA. |
| 25 | |
| 26 | ;;; Commentary: |
| 27 | |
| 28 | ;; This module defines some utility functions for STARTTLS profiles. |
| 29 | |
| 30 | ;; [RFC 2595] "Using TLS with IMAP, POP3 and ACAP" |
| 31 | ;; by Chris Newman <chris.newman@innosoft.com> (1999/06) |
| 32 | |
| 33 | ;;; Code: |
| 34 | |
| 35 | (defgroup starttls nil |
| 36 | "Support for `Transport Layer Security' protocol." |
| 37 | :version "21.1" |
| 38 | :group 'mail) |
| 39 | |
| 40 | (defcustom starttls-program "starttls" |
| 41 | "The program to run in a subprocess to open an TLSv1 connection." |
| 42 | :type 'string |
| 43 | :group 'starttls) |
| 44 | |
| 45 | (defcustom starttls-extra-args nil |
| 46 | "Extra arguments to `starttls-program'." |
| 47 | :type '(repeat string) |
| 48 | :group 'starttls) |
| 49 | |
| 50 | (defun starttls-negotiate (process) |
| 51 | (signal-process (process-id process) 'SIGALRM)) |
| 52 | |
| 53 | (defun starttls-open-stream (name buffer host service) |
| 54 | "Open a TLS connection for a service to a host. |
| 55 | Returns a subprocess-object to represent the connection. |
| 56 | Input and output work as for subprocesses; `delete-process' closes it. |
| 57 | Args are NAME BUFFER HOST SERVICE. |
| 58 | NAME is name for process. It is modified if necessary to make it unique. |
| 59 | BUFFER is the buffer (or `buffer-name') to associate with the process. |
| 60 | Process output goes at end of that buffer, unless you specify |
| 61 | an output stream or filter function to handle the output. |
| 62 | BUFFER may be also nil, meaning that this process is not associated |
| 63 | with any buffer |
| 64 | Third arg is name of the host to connect to, or its IP address. |
| 65 | Fourth arg SERVICE is name of the service desired, or an integer |
| 66 | specifying a port number to connect to." |
| 67 | (let* ((process-connection-type nil) |
| 68 | (process (apply #'start-process |
| 69 | name buffer starttls-program |
| 70 | host (format "%s" service) |
| 71 | starttls-extra-args))) |
| 72 | (process-kill-without-query process) |
| 73 | process)) |
| 74 | |
| 75 | (provide 'starttls) |
| 76 | |
| 77 | ;;; arch-tag: 648b3bd8-63bd-47f5-904c-7c819aea2297 |
| 78 | ;;; starttls.el ends here |