We all know how important it is to secure web servers with encryption. As I’ve mentioned before, port 80 HTTP should be considered deprecated at this point!
Just as important (potentially more so), but often overlooked, is to ensure that your email server is also secure.
STARTTLS is a technology that lets you start an encrypted session during a standard SMTP connection. In the same way as HTTPS secures web, STARTTLS will secure email in transit from your mail client to the server, and from server to server. This makes it much harder to passively read the traffic, and having more encrypted traffic on the internet is only ever a good thing.
This only protects email in transit from server to server of course, so this is not a replacement for end to end encryption methods like PGP, but it does complement it… and since most email is still sent insecurely, this adds extra security without requiring your users do any extra work.
It’s easy to set up (for Exim at least), and it transparently runs on port 25, so there’s no reason not to!
Generate your keys
As with web, you’ll need a server key and certificate file.
For my public mail and MX relay servers, I decided to use valid certificate authority certificates. Clients, and some relaying servers, will throw a certificate error for self signed certificates, but others will not. Better safe than sorry, and since I already had a valid certificate on my site for the server in question, I simply recycled the certificate.
If this is your internal server, you can use a certificate signed by your own certificate authority, supported by the machines in your organisation.
The default exim configuration expects to find certificates in
The basic STARTTLS configuration by simply editing
exim4.conf.template and setting
MAIN_TLS_ENABLE = yes in the tlsoptions section. Restart exim and you should have STARTTLS support enabled.
As with a web server, you can configure ciphers etc at this stage. On my server at least, the defaults seemed reasonably strong, but as we learn which ciphers have been compromised by GCHQ and the NSA, we might need to tweak these.
Test your configuration
Next, you should test your configuration.
To do this, the simplest way is to use a program called
swaks, which you should find in your distro’s package library.
swaks -a -tls -q HELO -s mail.example.com -au test -ap '<>'
Should produce a result something like…
=== Trying mail.example.com:25...
=== Connected to mail.example.com.
<- 220 TLS go ahead
=== TLS started w/ cipher ECDHE-RSA-AES256-GCM-SHA384
=== TLS peer subject DN="/OU=Domain Control Validated/OU=PositiveSSL/CN=mail.example.com"
<~ 221 mail.example.com closing connection
=== Connection closed with remote host.
If you get an error when starting TLS examine your exim log for the cause.