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:
You can also directly trigger the reload of postfix when the cert is renewed using this plugin:
{
events {
on cert_obtained exec /etc/init.d/postfix reload
}
}
Actually that triggers a reload for any cert that gets obtained (including renewals), but in the future we may make it possible to filter by event data.
Keep in mind that if Caddy uses ZeroSSL to issue a cert instead of Let’s Encrypt, your approach will break because the path to the files will be different. You can use events to get the correct path every time (it gets passed as input to the event handler)