Exim 4.72 release
[exim-website.git] / config.samples / C027
1 From: "Paul Makepeace" <Paul.Makepeace@realprogrammers.com>
2 Date: Sat, 16 Oct 1999 02:03:04 -0500
3
4 Quickstart: do everything following the # signs as root
5
6 This is an FYI to demonstrate how to have exim work with SSL using the
7 stunnel wrapper and its underlying OpenSSL libraries and toolkit. It's
8 intended as a recipe; there are plenty of explanations about the underlying
9 technology (start at http://mike.daewoo.com.pl/computer/stunnel/ ) but little
10 up-to-date cookbook info (that I could find) and the manpages left me
11 guessing.
12
13 My goal was not to compile anything. This unfortunately required me moving to
14 Debian 2.2, the unstable branch that contained these new packages. This note
15 is thus Debian-oriented but not -specific.
16
17 Stunnel requires a X.509 certificate to operate and comes with one by default
18 in the Debian stunnel package. For my purposes though it was useless since
19 Outlook Express (and I'm sure many others) check the Common Name matched the
20 hostname it's connecting too.
21
22 The certificate generation can be done in this four step process in lieu of
23 obtaining a signed one from Thawte or Verisign (not sure why one would do
24 that in this instance):
25
26 Generate RSA key:
27
28 ## mkdir -p /etc/ssl/certs
29 # cd /etc/ssl/certs
30 # cat > README < this-email; # :-)
31
32 # openssl genrsa 1024 > exim.rsa
33
34 Generate Diffie-Hellman parameters:
35
36 # openssl gendh -rand /dev/urandom > exim.dh
37
38 Generate certificate using the RSA key without a passphrase (explained in
39 docs):
40
41 # openssl req -new -x509 -nodes -key exim.rsa -out exim.x509
42
43 The important point here is to enter the hostname into the Common Name field
44 as it's entered into the mail client. Without this the mail client may
45 question you for every connection about this mismatch. The data to this and
46 other questions can be set up in /usr/local/openssl/openssl.cnf . The fields
47 can be given defaults by adding _default to the attribute name (examples
48 already in there).
49
50 At this point create the stunnel-ready file by stringing those three
51 together:
52
53 # cat exim.rsa exim.pem exim.x509 exim.dh > exim.pem
54
55 Run exim in daemon mode under stunnel on the ssmtp port (and imapd to
56 complete the story):
57
58 (suitably hack /etc/init.d/* as follows:)
59
60 # cp exim.pem imapd.pem
61 # chmod 600 exim.pem imapd.pem
62 # chown mail exim.pem
63 # stunnel -d 465 -l /usr/sbin/exim -p exim.pem -- exim -bs
64 # stunnel -d 993 -l /usr/sbin/imapd -p imapd.pem -- imapd
65
66 The name given after the -- on the command line is the name the service is
67 run as so using say exim-ssl would, since stunnel can use libwrap (of TCP
68 Wrappers fame), allow a separately configured access policy in
69 /etc/hosts.(allow|deny)
70
71 To run exim in inetd mode (not recommended apparently because of the
72 connection cost) requires a adding 127.0.0.1 to the host_accept_relay
73 directive in /etc/exim.conf since stunnel invokes it through the loopback
74 interface. I suspect this actually would defeat the point of this directive
75 in practice if spammers ever figured out how to connect to an SSL MTA thus
76 configured...
77
78 The magic line in /etc/inetd.conf is (as a single line):
79
80 ssmtp stream tcp nowait mail /usr/sbin/stunnel exim -l /usr/sbin/exim -p
81 /etc/ssl/certs/exim.pem -- exim -bs
82
83 ...with in /etc/services:
84
85 ssmtp           465/tcp                         # SMTP over SSL
86
87
88 Corrections & improvements appreciated!
89
90 Enjoy,
91 Paul