docker-mailserver/docs/content/config/security/ssl.md

63 lines
2.9 KiB
Markdown
Raw Normal View History

2016-02-10 08:49:22 +00:00
There are multiple options to enable SSL:
* using [letsencrypt](https://letsencrypt.org/) (recommended)
* using self-signed certificates with the provided tool
After installation, you can test your setup with [checktls.com](https://www.checktls.com/TestReceiver).
2016-02-10 08:51:31 +00:00
### Let's encrypt (recommended)
2016-02-10 08:49:22 +00:00
To enable Let's Encrypt on your mail server, you have to:
* get your certificate using [letsencrypt client](https://github.com/letsencrypt/letsencrypt)
2016-04-24 15:16:23 +00:00
* add an environment variable `SSL_TYPE` with value `letsencrypt` (see `docker-compose.yml.dist`)
2016-02-10 08:49:22 +00:00
* mount your whole `letsencrypt` folder to `/etc/letsencrypt`
* the certs folder name located in `letsencrypt/live/` must be the `fqdn` of your container responding to the `hostname` command. The full qualified domain name (`fqdn`) inside the docker container is build combining the `hostname` and `domainname` values of the docker-compose file, e. g.: hostname: `mail`; domainname: `myserver.tld`; fqdn: `mail.myserver.tld`
2016-02-10 08:49:22 +00:00
You don't have anything else to do. Enjoy.
2016-02-10 08:51:31 +00:00
### Self-signed certificates (testing only)
2016-02-10 08:49:22 +00:00
You can easily generate a self-signed SSL certificate by using the following command:
2016-08-17 12:38:35 +00:00
docker run -ti --rm -v "$(pwd)"/config/ssl:/ssl -h mail.my-domain.com -t tvial/docker-mailserver generate-ssl-certificate
2016-02-10 08:49:22 +00:00
# Press enter
# Enter a password when needed
# Fill information like Country, Organisation name
# Fill "my-domain.com" as FQDN for CA, and "mail.my-domain.com" for the certificate.
# They HAVE to be different, otherwise you'll get a `TXT_DB error number 2`
# Don't fill extras
# Enter same password when needed
# Sign the certificate? [y/n]:y
# 1 out of 1 certificate requests certified, commit? [y/n]y
# will generate:
2016-08-17 12:38:35 +00:00
# config/ssl/mail.my-domain.com-key.pem (used in postfix)
# config/ssl/mail.my-domain.com-req.pem (only used to generate other files)
# config/ssl/mail.my-domain.com-cert.pem (used in postfix)
# config/ssl/mail.my-domain.com-combined.pem (used in courier)
# config/ssl/demoCA/cacert.pem (certificate authority)
2016-02-10 08:49:22 +00:00
Note that the certificate will be generate for the container `fqdn`, that is passed as `-h` argument.
Check the following page for more information regarding [postfix and SSL/TLS configuration](http://www.mad-hacking.net/documentation/linux/applications/mail/using-ssl-tls-postfix-courier.xml).
To use the certificate:
2016-08-31 14:28:52 +00:00
* add `SSL_TYPE=self-signed` to your container environment variables
2016-08-17 12:38:35 +00:00
* if a matching certificate (files listed above) is found in `config/ssl`, it will be automatically setup in postfix and courier-imap-ssl. You just have to place them in `config/ssl` folder.
2016-02-10 08:49:22 +00:00
### Testing certificate
From your host:
docker exec mail openssl s_client -connect 0.0.0.0:25 -starttls smtp -CApath /etc/ssl/certs/
or
docker exec mail openssl s_client -connect 0.0.0.0:143 -starttls imap -CApath /etc/ssl/certs/
And you should see the certificate chain, the server certificate and:
Verify return code: 0 (ok)