Skip to content

Commit 56fcafc

Browse files
authored
Merge pull request #660 from tlhackque/master
Update from tlhackque/getssl
2 parents d8006d6 + db2ec98 commit 56fcafc

14 files changed

+202
-65
lines changed

.gitattributes

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
# Files not to include in .zip/.tar.gz archives
2+
#
3+
.git* export-ignore
4+
15
# Handle line endings automatically for files detected as text
26
# and leave all files detected as binary untouched.
37
* text=auto
48

59
# Make all text files lf formatted
610
* text eol=lf
11+

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*~
2+
*#
3+
*.swp
4+
*.tmp
5+
*.bak
6+
*.tdy
7+
*.tar.gz
8+
*.orig
9+
JSON.sh

Makefile

+3-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ ifneq ($(strip $(DESTDIR)),)
1919
mkdir -p $(DESTDIR)
2020
endif
2121

22-
install -Dm755 getssl $(DESTDIR)/usr/bin/getssl
23-
24-
install -dm755 $(DESTDIR)/usr/share/getssl
25-
cp -r *_scripts $(DESTDIR)/usr/share/getssl
22+
install -Dvm755 getssl $(DESTDIR)/usr/bin/getssl
23+
install -dvm755 $(DESTDIR)/usr/share/getssl
24+
for dir in *_scripts; do install -dv $(DESTDIR)/usr/share/getssl/$$dir; install -pv $$dir/* $(DESTDIR)/usr/share/getssl/$$dir/; done
2625

2726
.PHONY: install
2827

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ certificates to a remote server ( providing you have a ssh with key,
8989
sftp or ftp access to the remote server).
9090

9191
```getssl -h
92-
getssl ver. 2.35
92+
getssl ver. 2.36
9393
Obtain SSL certificates from the letsencrypt.org ACME server
9494
9595
Usage: getssl [-h|--help] [-d|--debug] [-c|--create] [-f|--force] [-a|--all] [-q|--quiet] [-Q|--mute] [-u|--upgrade] [-k|--keep #] [-U|--nocheck] [-r|--revoke cert key] [-w working_dir] [--preferred-chain chain] domain
@@ -107,6 +107,7 @@ Options:
107107
-u, --upgrade Upgrade getssl if a more recent version is available - can be used with or without domain(s)
108108
-k, --keep "#" Maximum number of old getssl versions to keep when upgrading
109109
-U, --nocheck Do not check if a more recent version is available
110+
-v --version Display current version of getssl
110111
-w working_dir "Working directory"
111112
--preferred-chain "chain" Use an alternate chain for the certificate
112113
```
@@ -376,7 +377,7 @@ Usage: `getssl -r path/to/cert path/to/key [CA_server]`
376377
You need to specify both the certificate you want to revoke, and the
377378
account or private domain key which was used to sign / obtain the
378379
original certificate. The `CA_server` is an optional parameter and
379-
defaults to Let's Encrypt ("<https://acme-v01.api.letsencrypt.org>") as
380+
defaults to Let's Encrypt ("<https://acme-v02.api.letsencrypt.org>") as
380381
that is currently the only Certificate Authority using the ACME
381382
protocol.
382383

dns_scripts/00GoDaddy-README.txt

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
Using GoDaddy DNS for LetsEncrypt domain validation.
2+
3+
Quick guide to setting up getssl for domain validation of
4+
GoDaddy DNS domains.
5+
6+
There are two prerequisites to using getssl with GoDaddy DNS:
7+
8+
1) Obtain an API access key from developer.godaddy.com
9+
At first sign-up, you will be required to take a "test" key.
10+
This is NOT what you need. Accept it, then get a "Production"
11+
key. At this writing, there is no charge - but you must have
12+
a GoDaddy customer account.
13+
14+
You must get the API key for the account which owns the domain
15+
that you want to get certificates for. If the domains that you
16+
manage are owned by more than one account, get a key for each.
17+
18+
The access key consists of a "Key" and a "Secret". You need
19+
both.
20+
21+
2) Obtain JSON.sh - https://github.com/dominictarr/JSON.sh
22+
23+
With those in hand, the installation procedure is:
24+
25+
1) Put JSON.sh in the getssl DNS scripts directory
26+
Default: /usr/share/getssl/dns_scripts
27+
28+
2) Open your config file (the global file in ~/.getssl/getssl.cfg
29+
or the per-account file in ~/.getssl/example.net/getssl.cfg
30+
31+
3) Set the following options:
32+
VALIDATE_VIA_DNS="true"
33+
DNS_ADD_COMMAND="/usr/share/getssl/dns_scripts/dns_add_godaddy"
34+
DNS_DEL_COMMAND="/usr/share/getssl/dns_scripts/dns_del_godaddy"
35+
# The API key for your account/this domain
36+
export GODADDY_KEY="..." GODADDY_SECRET="..."
37+
# The base domain name(s) in which the challege records are stored
38+
# E.g. if www.example.net is in the example.net zone:
39+
export GODADDY_BASE="example.com example.net"
40+
41+
4) Set any other options that you wish (per the standard
42+
directions.) Use the test CA to make sure that
43+
everything is setup correctly.
44+
45+
That's it. getssl example.net will now validate with DNS.
46+
47+
To trace record additions and removals, run getssl as
48+
GODADDY_TRACE=Y getssl example.net
49+
50+
There are additional options, which are documented in the
51+
*godaddy" files and dns_godaddy -h.
52+
53+
Copyright (C) 2017, 2018 Timothe Litt litt at acm _dot org
54+
55+
This sofware may be freely used providing this notice is included with
56+
all copies. The name of the author may not be used to endorse
57+
any other product or derivative work. No warranty is provided
58+
and the user assumes all responsibility for use of this software.
59+
60+
Report any issues to https://github.com/tlhackque/getssl/issues.
61+
62+
Enjoy.
63+

dns_scripts/dns_add_godaddy

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# Copyright (2017) Timothe Litt litt at acm _dot org
3+
# Copyright (C) 2017, 2018 Timothe Litt litt at acm _dot org
44

55
# Add token to GoDaddy dns using dns_godaddy
66

@@ -36,5 +36,6 @@ fi
3636

3737
export GODADDY_KEY
3838
export GODADDY_SECRET
39+
export GODADDY_BASE
3940

40-
$GODADDY_SCRIPT -q add "${fulldomain}" "_acme-challenge" "${token}"
41+
$GODADDY_SCRIPT -q add "${fulldomain}" "_acme-challenge.${fulldomain}." "${token}"

dns_scripts/dns_add_nsupdate

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ if [ -n "${DNS_NSUPDATE_KEYFILE}" ]; then
2121
options="-k ${DNS_NSUPDATE_KEYFILE}"
2222
fi
2323

24+
cmd=
2425
if [ -n "${DNS_SERVER}" ]; then
25-
cmd+="server ${DNS_SERVER}\n"
26+
cmd+="server ${DNS_SERVER}\n"
2627
fi
2728

2829
cmd+="update add ${DNS_ZONE:-"_acme-challenge.${fulldomain}."} 300 in TXT \"${token}\"\n"

dns_scripts/dns_del_godaddy

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# Copyright (2017) Timothe Litt litt at acm _dot org
3+
# Copyright (C) 2017,2018 Timothe Litt litt at acm _dot org
44

55
# Remove token from GoDaddy dns using dns_godaddy
66

@@ -24,7 +24,7 @@ token="$2"
2424

2525
[ -z "$GODADDY_SCRIPT" ] && GODADDY_SCRIPT="/usr/share/getssl/dns_scripts/dns_godaddy"
2626
[[ "$GODADDY_SCRIPT" =~ ^~ ]] && \
27-
eval 'GODADDY_SCRIPT=`readlink -nf ' "$GODADDY_SCRIPT" '`'
27+
eval 'GODADDY_SCRIPT=`readlink -nf ' $GODADDY_SCRIPT '`'
2828

2929
if ! [ -x "$GODADDY_SCRIPT" ]; then
3030
echo "$GODADDY_SCRIPT: not found. Please install, softlink or set GODADDY_SCRIPT to its full path"
@@ -34,5 +34,6 @@ fi
3434

3535
export GODADDY_KEY
3636
export GODADDY_SECRET
37+
export GODADDY_BASE
3738

3839
$GODADDY_SCRIPT -q del "${fulldomain}" "_acme-challenge.${fulldomain}." "${token}"

dns_scripts/dns_del_nsupdate

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ if [ -n "${DNS_NSUPDATE_KEYFILE}" ]; then
2121
options="-k ${DNS_NSUPDATE_KEYFILE}"
2222
fi
2323

24+
cmd=
2425
if [ -n "${DNS_SERVER}" ]; then
25-
cmd+="server ${DNS_SERVER}\n"
26+
cmd+="server ${DNS_SERVER}\n"
2627
fi
2728

2829
cmd+="update delete ${DNS_ZONE:-"_acme-challenge.${fulldomain}."} 300 in TXT \"${token}\"\n"

dns_scripts/dns_godaddy

100644100755
+31-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash
22

3-
# Copyright (2017) Timothe Litt litt at acm _dot org
3+
# Copyright (C) 2017,2018 Timothe Litt litt at acm _dot org
44

5-
VERSION="1.0.1"
5+
VERSION="1.0.3"
66
PROG="`basename $0`"
77

88
# This script is used to update TXT records in GoDaddy DNS server
@@ -31,6 +31,7 @@ DEBUG="$GODADDY_DEBUG"
3131

3232
while getopts 'dhj:k:s:t:qv' opt; do
3333
case $opt in
34+
b) GODADDY_BASE="$OPTARG" ;;
3435
d) DEBUG="Y" ;;
3536
j) JSON="$OPTARG" ;;
3637
k) GODADDY_KEY="$OPTARG" ;;
@@ -72,6 +73,9 @@ Arguments:
7273
For minimal trace output (to override -q), define GODADDY_TRACE="y".
7374
7475
Options
76+
-b Domain name(s) in which challenge records are stored
77+
E.g. often, www.example.net is stored in example.net.
78+
Default from GODADDY_BASE
7579
-d Provide debugging output - all requests and responses
7680
-h This help.
7781
-j: Location of JSON.sh Default `dirname $0`/JSON.sh, or
@@ -84,6 +88,7 @@ Options
8488
All output, except for this help text, is to stderr.
8589
8690
Environment variables
91+
GODADDY_BASE Domain name(s) in which challenge records are stored
8792
GODADDY_JSON location of the JSOH.sh script
8893
GODADDY_KEY default API key
8994
GODADDY_SCRIPT location of this script, default location of JSON.sh
@@ -92,7 +97,7 @@ Environment variables
9297
GODADDY_TFILE appends protocol trace to file. Overrides -t
9398
9499
BUGS
95-
Due to a limitation of the gOdADDY API, deleting the last TXT record
100+
Due to a limitation of the GoDaddy API, deleting the last TXT record
96101
would be too risky for my taste. So in that case, I replace it with
97102
_dummy.record_.domain. TXT "Ihis record is not used". This record is
98103
not automatically deleted by this script, though it's perfectly OK to
@@ -155,6 +160,7 @@ if [ -z "$name" ]; then
155160
echo "'name' parameter is required, see -h" >&2
156161
exit 3
157162
fi
163+
! [[ "$name" =~ [.]$ ]] && name="${name}.${domain}."
158164
data="$4"
159165
if [ -z "$data" ]; then
160166
echo "'data' parameter is required, see -h" >&2
@@ -206,7 +212,23 @@ if [ "$op" = "add" ]; then
206212

207213
while [[ "$domain" =~ [^.]+\.[^.]+ ]]; do
208214

209-
url="$API/$domain/records/TXT/$name"
215+
reqname="$name"
216+
# The API doesn't trim the base domain from the name (it used to)
217+
# If specified, remove any listed base.
218+
if [ -n "$GODADDY_BASE" ]; then
219+
for GDB in $GODADDY_BASE; do
220+
gdb="`echo "$GDB" | sed -e's/\\.$//;s/\\./\\\\./g;'`"
221+
gdb="^(.+)\\.$gdb\\.?$"
222+
if [[ "$name" =~ $gdb ]]; then
223+
reqname="${BASH_REMATCH[1]}"
224+
break;
225+
fi
226+
done
227+
else
228+
eval 'reqname="$''{name%'"'.$domain.'}"'"'
229+
fi
230+
231+
url="$API/$domain/records/TXT/$reqname"
210232

211233
request='[{"data":"'$data'","ttl":'$ttl'}]'
212234
[ -n "$DEBUG" ] && cat >&2 <<EOF
@@ -332,10 +354,14 @@ Old TXT RRSET:
332354
$current
333355
EOF
334356

335-
# Remove the desired record. The name must be relative.
357+
# Remove the desired record. The name must be relative. Order varies.
336358

337359
eval 'name="$''{name%'"'.$domain.'}"'"'
338360

361+
match="$(printf '"name":"%s","data":"%s","ttl":' "$name" "$data")"
362+
cmd="$(printf 'echo %s%s%s | grep -v %s%s%s' "'" "$current" "'" "'" "$match" "'")"
363+
eval 'new="$('"$cmd"')"'
364+
339365
match="$(printf '"data":"%s","name":"%s","ttl":' "$data" "$name")"
340366
cmd="$(printf 'echo %s%s%s | grep -v %s%s%s' "'" "$current" "'" "'" "$match" "'")"
341367
eval 'new="$('"$cmd"')"'

0 commit comments

Comments
 (0)