2018-12-11 08:44:46 -06:00
|
|
|
# Use a bought SSL certificate
|
2015-01-07 09:12:18 -06:00
|
|
|
|
|
|
|
[TOC]
|
|
|
|
|
|
|
|
iRedMail generates a self-signed SSL certificate during installation, it's
|
|
|
|
fine if you just want to secure the network connections (POP3/IMAP/SMTP over
|
|
|
|
TLS, HTTPS), but mail clients or web browsers will promot a annoying message
|
|
|
|
to warn you this self-signed certificate is not trusted. To avoid this
|
|
|
|
annoying message, you have to buy a SSL certificate from SSL certificate
|
|
|
|
provider. Search `buy ssl certificate` in Google will give you many SSL
|
|
|
|
providers, choose the one you prefer.
|
|
|
|
|
2017-02-17 20:23:25 -06:00
|
|
|
## Get a SSL certificate
|
2015-01-07 10:33:05 -06:00
|
|
|
|
2018-12-11 08:44:46 -06:00
|
|
|
### Request a free cert from Let's Encrypt
|
2015-01-07 09:12:18 -06:00
|
|
|
|
2018-12-11 08:44:46 -06:00
|
|
|
We have another tutorial to show you to request a free cert from Let's Encrypt:
|
|
|
|
[Request a free cert from Let's Encrypt](./letsencrypt.html).
|
2017-02-17 20:23:25 -06:00
|
|
|
|
|
|
|
### Buy from a trusted SSL vendor
|
|
|
|
|
|
|
|
To buy ssl cert from a trusted vendor, you need to generate a new SSL
|
|
|
|
key and signing request file on your server with `openssl` command:
|
|
|
|
|
|
|
|
!!! warning
|
|
|
|
|
|
|
|
Do NOT use key length smaller than `2048` bit, it's insecure.
|
2015-01-07 09:12:18 -06:00
|
|
|
|
|
|
|
```
|
2017-10-12 19:53:42 -05:00
|
|
|
# openssl req -new -newkey rsa:2048 -nodes -keyout privkey.pem -out server.csr
|
2015-01-07 09:12:18 -06:00
|
|
|
```
|
|
|
|
|
|
|
|
This command will generate two files:
|
|
|
|
|
2017-10-12 19:53:42 -05:00
|
|
|
* `privkey.pem`: the private key for the decryption of your SSL certificate.
|
2015-01-07 09:12:18 -06:00
|
|
|
* `server.csr`: the certificate signing request (CSR) file used to apply
|
2015-05-14 20:54:55 -05:00
|
|
|
for your SSL certificate. __This file is required by SSL certificate
|
2015-05-10 07:29:07 -05:00
|
|
|
provider.__
|
2015-01-07 09:12:18 -06:00
|
|
|
|
|
|
|
The openssl command will prompt for the following X.509 attributes of the
|
|
|
|
certificate:
|
|
|
|
|
|
|
|
* `Country Name (2 letter code)`: Use the two-letter code without punctuation
|
|
|
|
for country. for example: US, CA, CN.
|
|
|
|
* `State or Province Name (full name)`: Spell out the state completely; do not
|
|
|
|
abbreviate the state or province name, for example: California.
|
|
|
|
* `Locality Name (eg, city)`: City or town name, for example: Berkeley.
|
|
|
|
* `Organization Name (eg, company)`: Your company name.
|
|
|
|
* `Organizational Unit Name (eg, section)`: The name of the department or
|
|
|
|
organization unit making the request.
|
|
|
|
* `Common Name (e.g. server FQDN or YOUR name)`: server FQDN or your name.
|
|
|
|
* `Email Address []`: your full email address.
|
|
|
|
* `A challenge password []`: type a password for this ssl certificate.
|
|
|
|
* `An optional company name []`: an optional company name.
|
|
|
|
|
2015-08-14 08:25:15 -05:00
|
|
|
__NOTE__: Some certificates can only be used on web servers using the `Common Name`
|
2015-01-07 09:12:18 -06:00
|
|
|
specified during enrollment. For example, a certificate for the domain
|
|
|
|
`domain.com` will receive a warning if accessing a site named `www.domain.com`
|
|
|
|
or `secure.domain.com`, because `www.domain.com` and `secure.domain.com` are
|
|
|
|
different from `domain.com`.
|
|
|
|
|
2017-10-12 19:53:42 -05:00
|
|
|
Now you have two files: `privkey.pem` and `server.csr`. Go to the website of
|
2015-01-07 09:12:18 -06:00
|
|
|
your preferred SSL privider, it will ask you to upload `server.csr` file to
|
|
|
|
issue an SSL certificate.
|
|
|
|
|
|
|
|
Usually, SSL provider will give you 2 files:
|
|
|
|
|
2018-12-11 08:44:46 -06:00
|
|
|
* `cert.pem`
|
|
|
|
* `fullchain.pem` (some SSL providers use name `server.ca-bundle`)
|
2015-01-07 09:12:18 -06:00
|
|
|
|
2017-10-12 19:53:42 -05:00
|
|
|
We need above 2 files, and `privkey.pem`. Upload them to your server, you can
|
2015-01-07 09:12:18 -06:00
|
|
|
store them in any directory you like, recommended directories are:
|
|
|
|
|
2017-10-12 19:53:42 -05:00
|
|
|
* on RHEL/CentOS: `cert.pem` and `fullchain.pem` should be placed under
|
|
|
|
`/etc/pki/tls/certs/`, `privkey.pem` should be `/etc/pki/tls/private/`.
|
|
|
|
* on Debian/Ubuntu, FreeBSD: `cert.pem` and `fullchain.pem` should be
|
|
|
|
placed under `/etc/ssl/certs/`, `privkey.pem` should be `/etc/ssl/private/`.
|
2015-01-07 09:12:18 -06:00
|
|
|
* on OpenBSD: `/etc/ssl/`.
|
|
|
|
|
2018-12-11 08:44:46 -06:00
|
|
|
## Use the bought cert
|
2015-01-07 09:12:18 -06:00
|
|
|
|
2018-12-11 08:44:46 -06:00
|
|
|
The easiest and quickest way to use the bought cert is replacing
|
|
|
|
the self-signed SSL cert generated by iRedMail installer, then
|
|
|
|
restart services which use the cert files.
|
2015-01-07 09:12:18 -06:00
|
|
|
|
2018-12-11 08:44:46 -06:00
|
|
|
### Replace cert files
|
2015-01-07 09:12:18 -06:00
|
|
|
|
2018-12-11 08:44:46 -06:00
|
|
|
* On RHEL/CentOS:
|
2015-01-07 09:12:18 -06:00
|
|
|
|
|
|
|
```
|
2018-12-11 08:44:46 -06:00
|
|
|
mv /etc/pki/tls/certs/iRedMail.crt{,.bak} # Backup. Rename iRedMail.crt to iRedMail.crt.bak
|
|
|
|
mv /etc/pki/tls/private/iRedMail.key{,.bak} # Backup. Rename iRedMail.key to iRedMail.key.bak
|
|
|
|
cp fullchain.pem /etc/pki/tls/certs/iRedMail.crt
|
|
|
|
cp privkey.pem /etc/pki/tls/private/iRedMail.key
|
2015-01-07 09:12:18 -06:00
|
|
|
```
|
|
|
|
|
2018-12-11 08:44:46 -06:00
|
|
|
* On Debian/Ubuntu, FreeBSD and OpenBSD:
|
2015-01-07 09:12:18 -06:00
|
|
|
|
|
|
|
```
|
2018-12-11 08:44:46 -06:00
|
|
|
mv /etc/ssl/certs/iRedMail.crt{,.bak} # Backup. Rename iRedMail.crt to iRedMail.crt.bak
|
|
|
|
mv /etc/ssl/private/iRedMail.key{,.bak} # Backup. Rename iRedMail.key to iRedMail.key.bak
|
|
|
|
cp fullchain.pem /etc/ssl/certs/iRedMail.crt
|
|
|
|
cp privkey.pem /etc/ssl/private/iRedMail.key
|
2016-12-30 19:41:59 -06:00
|
|
|
```
|
|
|
|
|
2018-12-11 08:44:46 -06:00
|
|
|
### Restart network services
|
2016-12-30 19:41:59 -06:00
|
|
|
|
2018-12-11 08:44:46 -06:00
|
|
|
Required services:
|
2015-10-18 05:18:17 -05:00
|
|
|
|
2018-12-11 08:44:46 -06:00
|
|
|
* Postfix
|
|
|
|
* Dovecot
|
|
|
|
* Nginx or Apache
|
2015-11-30 19:22:05 -06:00
|
|
|
|
2018-12-11 08:44:46 -06:00
|
|
|
Depends on the backend you chose during iRedMail installation, you may need to
|
|
|
|
restart:
|
2015-10-18 05:18:17 -05:00
|
|
|
|
2018-12-11 08:44:46 -06:00
|
|
|
* MySQL or MariaDB
|
|
|
|
* PostgreSQL
|
|
|
|
* OpenLDAP
|
2015-10-18 05:18:17 -05:00
|
|
|
|
2018-12-11 08:44:46 -06:00
|
|
|
## Verify the cert
|
2015-10-18 05:18:17 -05:00
|
|
|
|
2018-12-11 08:44:46 -06:00
|
|
|
* To verify ssl cert used in Postfix (SMTP server) and Dovecot, please launch a
|
|
|
|
mail client application (MUA, e.g. Outlook, Thunderbird) and create an email
|
|
|
|
account, make sure you correctly configured the MUA to connect to mail
|
|
|
|
server. If SSL cert is not valid, MUA will warn you.
|
|
|
|
* For Apache / Nginx web server, you can access your website with favourite web
|
|
|
|
browser, the browser should show you the ssl cert status. Or, use other
|
|
|
|
website to help test it, for example:
|
|
|
|
<https://www.ssllabs.com/ssltest/index.html> (input your web host name, then
|
|
|
|
submit and wait for a result).
|
2015-11-30 19:22:05 -06:00
|
|
|
|
2018-12-11 08:44:46 -06:00
|
|
|
## See Also
|
2015-06-26 20:50:52 -05:00
|
|
|
|
2018-12-11 08:44:46 -06:00
|
|
|
* [Request a free cert from Let's Encrypt](./letsencrypt.html)
|