Skip to content

Commit

Permalink
added push script option
Browse files Browse the repository at this point in the history
Added an option for a script, which will be called to install or remove a
response to a server. The script will have the following arguments:

script action domain token thumbprint

  action      either install or remove, based when the script is called
  domain      the domain for which the response should be added or removed
  token       the token under which the response is expected
  thumbprint  the thumbprint of the account key
  • Loading branch information
gheift committed Dec 13, 2015
1 parent 4bcf9ba commit a31ae66
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions letsencrypt.sh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ DOMAIN_DATA=
# $DOMAIN or ${DOMAIN} will be replaced with the actual domain # $DOMAIN or ${DOMAIN} will be replaced with the actual domain
WEBDIR= WEBDIR=


# the script to be called to push the response to a remote server
PUSH_TOKEN=

QUIET= QUIET=


# utility functions # utility functions
Expand Down Expand Up @@ -337,7 +340,9 @@ push_domain_response() {


if [ -n "$WEBDIR" ]; then if [ -n "$WEBDIR" ]; then
TOKEN_DIR="`printf "%s" $WEBDIR | sed -e 's/\$DOMAIN/'"$DOMAIN"'/g; s/${DOMAIN}/'"$DOMAIN"'/g'`" TOKEN_DIR="`printf "%s" $WEBDIR | sed -e 's/\$DOMAIN/'"$DOMAIN"'/g; s/${DOMAIN}/'"$DOMAIN"'/g'`"
printf "%s\n" "$DOMAIN_RESPONSE" > "$TOKEN_DIR/$DOMAIN_TOKEN" || exit 1 printf "%s.%s\n" "$DOMAIN_TOKEN.$ACCOUNT_THUMB" > "$TOKEN_DIR/$DOMAIN_TOKEN" || exit 1

This comment has been minimized.

Copy link
@warpedgeoid

warpedgeoid Jan 23, 2016

I'm not sure why this printf was changed from "%s\n" to "%s.%s\n" but doing so seems to break domain validation by including the extra period at the end of the verification token file. This causes LE verification attempts to fail with the message "Error parsing key authorization file: Invalid key authorization." Reverting this change fixes the issue.

elif [ -n "$PUSH_TOKEN" ]; then
$PUSH_TOKEN install "$DOMAIN" "$DOMAIN_TOKEN" "$ACCOUNT_THUMB" || die "could not install token for $DOMAIN"
fi fi


return return
Expand All @@ -352,6 +357,8 @@ remove_domain_response() {
if [ -n "$WEBDIR" ]; then if [ -n "$WEBDIR" ]; then
TOKEN_DIR="`printf "%s" $WEBDIR | sed -e 's/\$DOMAIN/'"$DOMAIN"'/g; s/${DOMAIN}/'"$DOMAIN"'/g'`" TOKEN_DIR="`printf "%s" $WEBDIR | sed -e 's/\$DOMAIN/'"$DOMAIN"'/g; s/${DOMAIN}/'"$DOMAIN"'/g'`"
rm -f "$TOKEN_DIR/$DOMAIN_TOKEN" rm -f "$TOKEN_DIR/$DOMAIN_TOKEN"
elif [ -n "$PUSH_TOKEN" ]; then
$PUSH_TOKEN remove "$DOMAIN" "$DOMAIN_TOKEN" "$ACCOUNT_THUMB" || exit 1
fi fi


return return
Expand All @@ -365,8 +372,6 @@ push_response() {
DOMAIN_TOKEN="$3" DOMAIN_TOKEN="$3"


shift 3 shift 3

DOMAIN_RESPONSE="$DOMAIN_TOKEN.$ACCOUNT_THUMB"


push_domain_response push_domain_response
done done
Expand Down Expand Up @@ -534,6 +539,8 @@ letsencrypt.sh sign -a account_key -r server_csr -c signed_crt
-w webdir the directory, where the response should be stored -w webdir the directory, where the response should be stored
$DOMAIN will be replaced by the actual domain $DOMAIN will be replaced by the actual domain
the directory will not be created the directory will not be created
-P exec the command to call to install the token on a remote
server
EOT EOT
} }


Expand Down Expand Up @@ -562,7 +569,7 @@ case "$ACTION" in
?|:) echo "invalid arguments" > /dev/stderr; exit 1;; ?|:) echo "invalid arguments" > /dev/stderr; exit 1;;
esac; done;; esac; done;;
sign) sign)
while getopts :hqa:k:r:c:w: name; do case "$name" in while getopts :hqa:k:r:c:w:P: name; do case "$name" in
h) usage; exit 1;; h) usage; exit 1;;
q) QUIET=1;; q) QUIET=1;;
a) ACCOUNT_KEY="$OPTARG";; a) ACCOUNT_KEY="$OPTARG";;
Expand All @@ -584,6 +591,7 @@ case "$ACTION" in
;; ;;
c) SERVER_CERT="$OPTARG";; c) SERVER_CERT="$OPTARG";;
w) WEBDIR="$OPTARG";; w) WEBDIR="$OPTARG";;
P) PUSH_TOKEN="$OPTARG";;
?|:) echo "invalid arguments" > /dev/stderr; exit 1;; ?|:) echo "invalid arguments" > /dev/stderr; exit 1;;
esac; done;; esac; done;;
-h|--help|-?) -h|--help|-?)
Expand Down

0 comments on commit a31ae66

Please sign in to comment.