Skip to content

Instantly share code, notes, and snippets.

@angel333
Last active November 16, 2023 13:46
Show Gist options
  • Save angel333/1aae17b1ea53a9cd538966979781d8aa to your computer and use it in GitHub Desktop.
Save angel333/1aae17b1ea53a9cd538966979781d8aa to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Certbot hook for Hurricane Electric DNS service
#
# Usage:
#
# Renew all certificates:
# HE_SESSID=<session_id> certbot renew \
# --preferred-challenges dns \
# --manual-auth-hook /path/to/certbot-he-hook.sh \
# --manual-public-ip-logging-ok
#
# Create a new certificate:
# HE_SESSID=<session_id> certbot certonly \
# --preferred-challenges dns \
# --email [email protected] \
# --manual \
# --manual-auth-hook /path/to/certbot-he-hook.sh \
# --manual-public-ip-logging-ok \
# --domain <requested.domain.com>
#
ZONENAME_REGEX=$(echo $CERTBOT_DOMAIN | awk -F '.' '{ print $(NF-1) "\\." $NF }')
HE_ZONEID=$(curl --stderr - --cookie CGISESSID=$HE_SESSID https://dns.he.net/index.cgi \
| grep -Eo "delete_dom.*name=\"$ZONENAME_REGEX\" value=\"[0-9]+" | grep -Eo "[0-9]+$")
curl --stderr - -o /dev/null --cookie CGISESSID=$HE_SESSID https://dns.he.net/index.cgi \
-d "account=&menu=edit_zone&Type=TXT&hosted_dns_zoneid=$HE_ZONEID&hosted_dns_recordid=&hosted_dns_editzone=1&Priority=&Name=_acme-challenge.$CERTBOT_DOMAIN&Content=$CERTBOT_VALIDATION&TTL=300&hosted_dns_editrecord=Submit"
@angel333
Copy link
Author

angel333 commented Jul 9, 2017

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