How to configure SSL for Dovecot/Postfix manually?

Ok so there are two ways:

First in answer to the original question:

Note: This is for those not using Virtualmin’s built in letsencrypt script.

You can either

1) Virtualmin > System Settings > Server Templates > SSL Website for Domain

Then choose custom paths and enter the letsencrypt paths for:

  • Template for private key path → /etc/letsencrypt/live/${DOM}/privkey.pem
  • Template for certificate path → /etc/letsencrypt/live/${DOM}/cert.pem
  • Template for CA certificate path → /etc/letsencrypt/live/${DOM}/chain.pem
  • Template for combined certificate path → /etc/letsencrypt/live/${DOM}/fullchain.pem
  • Template for key and certificates path (<<not sure about this one - is it needed?)

If you’re using your own letsencrypt script, just make sure on domain/account creation you don’t create the certs with that option.

2) Just copy the letsencrypt files to /home/domain.com/ named to what Virtualmin expects

I.e:

DOMAIN='NAMEHERE.com' sudo -E bash -c 'cp /etc/letsencrypt/live/$DOMAIN/privkey.pem /home/$DOMAIN/ssl.key'
DOMAIN='NAMEHERE.com' sudo -E bash -c 'cp /etc/letsencrypt/live/$DOMAIN/cert.pem /home/$DOMAIN/ssl.cert'
DOMAIN='NAMEHERE.com' sudo -E bash -c 'cp /etc/letsencrypt/live/$DOMAIN/chain.pem /home/$DOMAIN/ssl.ca'
DOMAIN='NAMEHERE.com' sudo -E bash -c 'cp /etc/letsencrypt/live/$DOMAIN/fullchain.pem /home/$DOMAIN/ssl.combined'

Second, how to configure accounts/domains that you have restored from an older server

Do one of the above AND make sure there are entries/mappings in:

1) Webmin > Servers > Postfix > Certificate Mapping

domain.com
/home/domain.com/ssl.key,/home/domain.com/ssl.cert,/home/domain.com/ssl.ca

And

.domain.com
/home/domain.com/ssl.key,/home/domain.com/ssl.cert,/home/domain.com/ssl.ca

2) Webmin > Servers > Dovecot > Edit Config Files (dovecot.conf)

Add to the bottom:

local_name *.domain.com {
  ssl_cert = </home/domain.com/ssl.combined
  ssl_key = </home/domain.com/ssl.key
}

If anyone things any of this is incorrect please let me know or update this post.