Skip to content

Instantly share code, notes, and snippets.

@sciguy16
Created June 21, 2020 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sciguy16/23fae554241695b22fd2963a9e77be51 to your computer and use it in GitHub Desktop.
Save sciguy16/23fae554241695b22fd2963a9e77be51 to your computer and use it in GitHub Desktop.
Certbot hooks to update a Windows DNS server
#!/bin/bash
# dns-cleanup.sh
# certbot hook to use nsupdate to send the validation to an Active Directory DNS server
nsupdate -g << EOF
update delete _acme-challenge.$CERTBOT_DOMAIN TXT
send
EOF
#!/bin/bash
# dns-update.sh
# certbot hook to use nsupdate to send the validation to an Active Directory DNS server
nsupdate -g << EOF
update add _acme-challenge.$CERTBOT_DOMAIN 100 TXT $CERTBOT_VALIDATION
send
EOF
echo "Starting sleeeep"
sleep 120
@sciguy16
Copy link
Author

sciguy16 commented Jun 21, 2020

nsupdate -g depends on kerberos having been intialised on the server with a service account in the DnsUpdateProxy AD group

Run certbot as:
certbot certonly --manual --preferred-challenges dns --test --manual-auth-hook ./dns-update.sh --manual-cleanup-hook ./dns-cleanup.sh -d example.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment