A Bash script to automatically update TLSA (DANE) DNS records on Cloudflare after certificate renewals. Adjust your domain in the sh-script, please!
- Loads Cloudflare API credentials from acme.sh's
account.conf - Fetches the live public key hashes (SHA-256) from:
tvipper.com:443(HTTPS)pmg01.tvipper.com:25(SMTP with STARTTLS)
- Compares them against the existing TLSA records in Cloudflare
- Updates any records that are out of date (DANE-EE, SPKI, SHA-256 — usage 3, selector 1, matching type 1)
The three TLSA records managed:
_443._tcp.tvipper.com_25._tcp.tvipper.com_25._tcp.pmg01.tvipper.com
bashopensslcurlpython3- acme.sh installed at
/root/.acme.sh/with Cloudflare credentials saved
chmod +x update_tlsa.sh
sudo ./update_tlsa.shRun this after each certificate renewal (e.g. via an acme.sh deploy hook or cron job).
To run automatically after acme.sh renews certificates, add it as a deploy hook or schedule it with cron:
0 3 * * * /path/to/update_tlsa.sh >> /var/log/update_tlsa.log 2>&1