Browse Source

More GoDaddy API changes

PUT now requires a relative domain name.
GET changed the order of name and data in the JSON.

Note: Due to the API changes, you may need to add
GODADDY_BASE to getssl.cfg.  This is a space-separated
list of base domain names (zones) in which the challenge
responses are entered.  There doesn't seem to be a way
around this that works in all cases, as the GoDaddy API
requires that the zone name be known.
pull/660/head
Timothe Litt 8 years ago
parent
commit
b6788320ce
4 changed files with 38 additions and 9 deletions
  1. +4
    -1
      dns_scripts/00GoDaddy-README.txt
  2. +2
    -1
      dns_scripts/dns_add_godaddy
  3. +2
    -1
      dns_scripts/dns_del_godaddy
  4. +30
    -6
      dns_scripts/dns_godaddy

+ 4
- 1
dns_scripts/00GoDaddy-README.txt View File

@ -34,6 +34,9 @@ With those in hand, the installation procedure is:
DNS_DEL_COMMAND="/usr/share/getssl/dns_scripts/dns_del_godaddy"
# The API key for your account/this domain
export GODADDY_KEY="..." GODADDY_SECRET="..."
# The base domain name(s) in which the challege records are stored
# E.g. if www.example.net is in the example.net zone:
export GODADDY_BASE="example.com example.net"
4) Set any other options that you wish (per the standard
directions.) Use the test CA to make sure that
@ -47,7 +50,7 @@ GODADDY_TRACE=Y getssl example.net
There are additional options, which are documented in the
*godaddy" files and dns_godaddy -h.
Copyright (2017) Timothe Litt litt at acm _dot org
Copyright (C) 2017, 2018 Timothe Litt litt at acm _dot org
This sofware may be freely used providing this notice is included with
all copies. The name of the author may not be used to endorse


+ 2
- 1
dns_scripts/dns_add_godaddy View File

@ -1,6 +1,6 @@
#!/bin/bash
# Copyright (2017) Timothe Litt litt at acm _dot org
# Copyright (C) 2017, 2018 Timothe Litt litt at acm _dot org
# Add token to GoDaddy dns using dns_godaddy
@ -36,5 +36,6 @@ fi
export GODADDY_KEY
export GODADDY_SECRET
export GODADDY_BASE
$GODADDY_SCRIPT -q add ${fulldomain} "_acme-challenge.${fulldomain}." "${token}"

+ 2
- 1
dns_scripts/dns_del_godaddy View File

@ -1,6 +1,6 @@
#!/bin/bash
# Copyright (2017) Timothe Litt litt at acm _dot org
# Copyright (C) 2017,2018 Timothe Litt litt at acm _dot org
# Remove token from GoDaddy dns using dns_godaddy
@ -34,5 +34,6 @@ fi
export GODADDY_KEY
export GODADDY_SECRET
export GODADDY_BASE
$GODADDY_SCRIPT -q del ${fulldomain} "_acme-challenge.${fulldomain}." "${token}"

+ 30
- 6
dns_scripts/dns_godaddy View File

@ -1,8 +1,8 @@
#!/bin/bash
# Copyright (C) 2017,2018) Timothe Litt litt at acm _dot org
# Copyright (C) 2017,2018 Timothe Litt litt at acm _dot org
VERSION="1.0.2"
VERSION="1.0.3"
PROG="`basename $0`"
# This script is used to update TXT records in GoDaddy DNS server
@ -31,6 +31,7 @@ DEBUG="$GODADDY_DEBUG"
while getopts 'dhj:k:s:t:qv' opt; do
case $opt in
b) GODADDY_BASE="$OPTARG" ;;
d) DEBUG="Y" ;;
j) JSON="$OPTARG" ;;
k) GODADDY_KEY="$OPTARG" ;;
@ -72,6 +73,9 @@ Arguments:
For minimal trace output (to override -q), define GODADDY_TRACE="y".
Options
-b Domain name(s) in which challenge records are stored
E.g. often, www.example.net is stored in example.net.
Default from GODADDY_BASE
-d Provide debugging output - all requests and responses
-h This help.
-j: Location of JSON.sh Default `dirname $0`/JSON.sh, or
@ -84,6 +88,7 @@ Options
All output, except for this help text, is to stderr.
Environment variables
GODADDY_BASE Domain name(s) in which challenge records are stored
GODADDY_JSON location of the JSOH.sh script
GODADDY_KEY default API key
GODADDY_SCRIPT location of this script, default location of JSON.sh
@ -92,7 +97,7 @@ Environment variables
GODADDY_TFILE appends protocol trace to file. Overrides -t
BUGS
Due to a limitation of the gOdADDY API, deleting the last TXT record
Due to a limitation of the GoDaddy API, deleting the last TXT record
would be too risky for my taste. So in that case, I replace it with
_dummy.record_.domain. TXT "Ihis record is not used". This record is
not automatically deleted by this script, though it's perfectly OK to
@ -207,7 +212,23 @@ if [ "$op" = "add" ]; then
while [[ "$domain" =~ [^.]+\.[^.]+ ]]; do
url="$API/$domain/records/TXT/$name"
reqname="$name"
# The API doesn't trim the base domain from the name (it used to)
# If specified, remove any listed base.
if [ -n "$GODADDY_BASE" ]; then
for GDB in $GODADDY_BASE; do
gdb="`echo "$GDB" | sed -e's/\\.$//;s/\\./\\\\./g;'`"
gdb="^(.+)\\.$gdb\\.?$"
if [[ "$name" =~ $gdb ]]; then
reqname="${BASH_REMATCH[1]}"
break;
fi
done
else
eval 'reqname="$''{name%'"'.$domain.'}"'"'
fi
url="$API/$domain/records/TXT/$reqname"
request='[{"data":"'$data'","ttl":'$ttl'}]'
[ -n "$DEBUG" ] && cat >&2 <<EOF
@ -216,7 +237,6 @@ Add request to: $url
$request"
--------
EOF
result="$(curl -i -s -X PUT -d "$request" --config - "$url" <<EOF
header = "Content-Type: application/json"
header = "$authhdr"
@ -333,7 +353,7 @@ Old TXT RRSET:
$current
EOF
# Remove the desired record. The name must be relative.
# Remove the desired record. The name must be relative. Order varies.
eval 'name="$''{name%'"'.$domain.'}"'"'
@ -341,6 +361,10 @@ match="$(printf '"name":"%s","data":"%s","ttl":' "$name" "$data")"
cmd="$(printf 'echo %s%s%s | grep -v %s%s%s' "'" "$current" "'" "'" "$match" "'")"
eval 'new="$('"$cmd"')"'
match="$(printf '"data":"%s","name":"%s","ttl":' "$data" "$name")"
cmd="$(printf 'echo %s%s%s | grep -v %s%s%s' "'" "$current" "'" "'" "$match" "'")"
eval 'new="$('"$cmd"')"'
if [ "$new" = "$base" ]; then
[ -n "$VERB" ] && echo "$domain: $name TXT \"$data\" does not exist" >&2
exit 1 # Intent was to change DNS, so this is an error


Loading…
Cancel
Save