If you happen to maintain Postfix and Caddy at the same time, it’s actually super easy to get a cert for Postfix.
I am running a bunch of instances that uses this Docker Caddy setup.
Add following to your Caddyfile, or in the setup above in the conf/caddyfile_optional.conf file:
mail.yourdomain.org {
respond "Hello"
log
}
When Caddy is reloaded you’ll get a cert. Again, in the example tutorial above the cert will end up in:
.caddy_data/caddy/certificates/acme-v02.api.letsencrypt.org-directory/mail.yourdomain.org
Symlink the crt/key files to your Postfix conf. I have added a symlink to the ordinary /etc folder:
mkdir -p /etc/letsencrypt/from-caddy
cd /etc/letsencrypt/from-caddy
ln -s /path/to/docker/.caddy_data/caddy/certificates/acme-v02.api.letsencrypt.org-directory/mail.yourdomain.org/mail.yourdomain.org.crt
ln -s /path/to/docker/.caddy_data/caddy/certificates/acme-v02.api.letsencrypt.org-directory/mail.yourdomain.org/mail.yourdomain.org.key
Then in the TLS-part of /etc/postfix/main.cf
:
smtpd_tls_cert_file = /etc/letsencrypt/from-caddy/mail.yourdomain.org.crt
smtpd_tls_key_file = /etc/letsencrypt/from-caddy/mail.yourdomain.org.key
To make sure Postfix always uses the latest cert, reload the conf with crontab:
0 0 * * 0 bash -lc '/etc/init.d/postfix reload'
That’s it. Butt ugly and works a charm!