previous next contents

IMAP Security - encryption and authentication


Security as it relates to IMAP implementations fall mainly into two categories - authentication, and encryption.

There a several ways to handle the authentication requirements. Basic IMAP authentication is no more secure than POP3 - it simply involves the passing of userid and password across the network as clear text.

As mentioned, the SASL library provides several methods by which this can be solved, allowing cryptographic challenge/response authentication methods to be tied in with a number of different authentication backends. However, this still provides no actual data security - message content is not encrypted if using these schemes.

To encrypt all communication between the client and server, it is necessary to use an SSL connection. Cyrus provides hooks for this, and can be compiled with support for IMAP/SSL via the use of the OpenSSL libraries.

The simplest method of setting this up is to use a self signed key. This can be prepared as follows:-

$ openssl req -new -x509 -nodes -out /var/imap/server.pem \
 -keyout /var/imap/server.pem -days 365

This generates a self-signed X509 certificate and private key pair in PEM format, which can be used to add SSL support to Cyrus with the following procedure.

Uncomment the imaps service definition in /etc/cyrus.conf, and add the following lines to /etc/imapd.conf:-

tls_cert_file: /var/imap/server.pem
tls_key_file: /var/imap/server.pem

For a more comprehesnive setup of this support, which can be useful if you intend to use SSL certs with several applications, you can use the OpenSSL toolkit to create your own certificate authority. You can then use this to sign all the SSL certs you generate. Doing this allows you to import the CSA public key into your browser/client, and then all the certificates signed with the corresponding private key will be accepted without bringing up confirmation dialog boxes. Created a RSA key using openssl. This will be the key for our local certifying authority.

To use this certificate, proceed as with the self-signed cert, also adding to the imapd.conf file a directive specifying the location of the X509 certificate of the CA.

tls_ca_file: /var/imap/ssl/ca.crt

You will need to import the certificate into your client's registry of known CA's. With Netscape, this is done be serving the certificate up via HTTP, with the appropriate mime-type. The following perl CGI will do this for you.

#!/usr/bin/perl
print "Content-type: application/x-x509-ca-cert\n\n";

open(CERTIFICATE, "/usr/local/ssl/private/ca.crt") || die "Unable to open cert\n";

foreach () {
        print;
}


previous next contents