Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/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 your@email.com \
# --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"
Owner

angel333 commented Jul 9, 2017

An improved version is here: https://github.com/angel333/certbot-he-hook

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