I have a mail server running postfix on Ubuntu 22.04 with certbot 2.11.0. The machine doesn't currently allow port 80 connections in or out (nor does it have a web server on it). I also run my own DNS (and can edit my zone files) using bind9.
I need to create (and preferably auto-renew) a cert for this (eg called mx.domain.com
).
Reading this, I think I understand I need to use:
sudo certbot certonly --manual --preferred-challeges dns -d mx.domain.com
and when it says:
For example, for the domain
example.com
, a zone file entry would look like:_acme-challenge.example.com. 300 IN TXT "gfj9Xq...Rg85nM"
I assume I enter:
_acme-challenge.mx.domain.com. 300 IN TXT "gfj9Xq...Rg85nM"
That is, use the name of the cert.
When it comes to renewal, I'm less clear. But it seems I need to set up a cron
job that runs before expiry (monthly?) and uses --manual-auth-hook
like this:
certbot certonly --manual --preferred-challenges=dns --manual-auth-hook /path/to/somescript.sh -d mx.domain.com
So in my case somescript.sh
needs to grab what certbot gives it for the TXT record, then replaces the existing key string in the zone file.
I think I can do that, but how do I get certbot to give the script the key string to use?
Bonus tangential question while I'm here:
Regardless of the above, if I need to add a domain to an existing cert, I assume I use:
sudo certbot certonly --cert-name mx.domain.com --expand --domains mx.domain.com, smtp.domain.com
Is that right?