How to сhange the default certificates for SMTP, IMAP, and POP3 over SSL?

Created:

2016-11-16 12:56:27 UTC

Modified:

2017-08-23 08:03:21 UTC

20

Was this article helpful?


Have more questions?

Submit a request

How to сhange the default certificates for SMTP, IMAP, and POP3 over SSL?

Applicable to:

  • Plesk for Linux

Question

How to change the default certificates for SMTP, IMAP, and POP3 over SSL?

Answer

The certificate for SMTP over SSL is located in the following files:

  1. For QMail MTA: /var/qmail/control/servercert.pem
  2. For Postfix MTA: /etc/postfix/postfix_default.pem
  3. For Dovecot: /etc/dovecot/private/ssl-cert-and-key.pem
  4. For a Courier-IMAP server (for IMAP4 and POP3 over SSL):
    /usr/share/imapd.pem
    /usr/share/pop3d.pem

    Or:

    /usr/share/courier-imap/imapd.pem
    /usr/share/courier-imap/pop3d.pem

By default, these are self-signed certificates for Plesk which are generated during the Plesk installation. If it is required to set up own certificates, copy and paste new certificate and private key to the appropriate files (create a backup before changing any files) and restart the qmail/postfix and courier-imap/dovecot  services (for Plesk version 9.x and later):

# /usr/local/psa/admin/sbin/mailmng --restart-service

The certificate must contain name of the domain it was issued for. This is to avoid a warning that the certificate name does not match that of the host mail client is connecting to. For example, if the certificate was issued for example.com, then example.com should be specified as the connection string in mail client preferences for SMTP/POP3/IMAP servers.

NOTE : There is a single certificate for each of these services: SMTP, IMAP4, and POP3 over SSL. Multiple certificates cannot be used for multiple Plesk domains.

Additional information

/var/qmail/control/servercert.pem should include:

  1. The Private Key
  2. The primary certificate
  3. The intermediate certificate
  4. The root certificate

Make sure that the begin and end tags of the key are included, along with the dash lines. The resulting text should look like:

    -----BEGIN RSA PRIVATE KEY-----
..........
(Your Private Key here)
..........
-----END RSA PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
..........
(Your Primary SSL certificate here)
..........
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
..........
(Your Intermediate certificate here)
..........
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
..........
(Your Root certificate here)
..........
-----END CERTIFICATE-----

The body of the SSL certificate in /usr/share/imapd.pem and /usr/share/pop3d.pem should look like:

    -----BEGIN PRIVATE KEY-----
MIIB8TCCAZsCBEUpHKkwDQYJKoZIhvcNAQEEBQAwgYExCzAJBgNVBAYTAlJPMQww
............
............
eNpAIeF34UctLcHkZJGIK6b9Gktm
-----END PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
MIICXgIBAAKBgQDv6i/mxtS2B2PjShArtOAmdRoEcCWa/LH1GcrbW14zdbmIqrxb
..........
..........
faXRHcG37TkvglUZ3wgy6eKuyrDi5gkwV8WAuaoNct5j5w==
-----END CERTIFICATE-----

The SSL certificate can only be installed together with the appropriate Private Key that was generated with Certificate Signed Request (CSR) used by the Certificate Authority to generate the certificate. The private key is only stored on the server, and this cannot be rebuilt to match an existing certificate.

If the private key has been lost, the certificate can no longer be installed.

To install the SSL certificate, find the private key. If this is not possible to locate the private key, contact the Certificate Authority who issued the certificate. They will reissue the SSL certificate.


Refer the following KB article to install SSL certificate issued for domain:

How to install SSL certificate issued for domain

Have more questions? Submit a request
Please sign in to leave a comment.