Skip to content

Commit

Permalink
release 0.6.4 (fixed account id handling, again)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas2511 committed Jun 25, 2019
1 parent f9d0b1b commit 4f358e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change Log
This file contains a log of major changes in dehydrated

## [0.6.4] - 2019-06-25
## Changed
- Fetch account ID from Location header instead of account json

## [0.6.3] - 2019-06-25
## Changed
- OCSP refresh interval is now configurable
Expand Down
17 changes: 10 additions & 7 deletions dehydrated
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ umask 077 # paranoid umask, we're creating private keys
exec 3>&-
exec 4>&-

VERSION="0.6.3"
VERSION="0.6.4"

# Find directory in which this script is stored by traversing all symbolic links
SOURCE="${0}"
Expand Down Expand Up @@ -246,6 +246,7 @@ load_config() {
[[ -f "${ACCOUNTDIR}/${CAHASH}/config" ]] && . "${ACCOUNTDIR}/${CAHASH}/config"
ACCOUNT_KEY="${ACCOUNTDIR}/${CAHASH}/account_key.pem"
ACCOUNT_KEY_JSON="${ACCOUNTDIR}/${CAHASH}/registration_info.json"
ACCOUNT_ID_JSON="${ACCOUNTDIR}/${CAHASH}/account_id.json"

if [[ -f "${BASEDIR}/private_key.pem" ]] && [[ ! -f "${ACCOUNT_KEY}" ]]; then
echo "! Moving private_key.pem to ${ACCOUNT_KEY}"
Expand Down Expand Up @@ -333,6 +334,7 @@ init_system() {
echo "Using private key ${PARAM_ACCOUNT_KEY} instead of account key"
ACCOUNT_KEY="${PARAM_ACCOUNT_KEY}"
ACCOUNT_KEY_JSON="${PARAM_ACCOUNT_KEY}.json"
ACCOUNT_ID_JSON="${PARAM_ACCOUNT_KEY}_id.json"
[ "${COMMAND:-}" = "register" ] && register_new_key="yes"
else
# Check if private account key exists, if it doesn't exist yet generate a new one (rsa key)
Expand Down Expand Up @@ -401,13 +403,14 @@ init_system() {

# Read account information or request from CA if missing
if [[ -e "${ACCOUNT_KEY_JSON}" ]]; then
if [[ -z "$(cat "${ACCOUNT_KEY_JSON}" | get_json_int_value id)" ]]; then
echo "+ Fetching account information..."
if [[ ! -e "${ACCOUNT_ID_JSON}" ]]; then
echo "+ Fetching account ID..."
ACCOUNT_URL="$(signed_request "${CA_NEW_ACCOUNT}" '{"onlyReturnExisting": true}' 4>&1 | grep -i ^Location: | awk '{print $2}' | tr -d '\r\n')"
ACCOUNT_INFO="$(signed_request "${ACCOUNT_URL}" '{}')"
echo "${ACCOUNT_INFO}" > "${ACCOUNT_KEY_JSON}"
ACCOUNT_ID="${ACCOUNT_URL##*/}"
echo '{"id": "'"${ACCOUNT_ID}"'"}' > "${ACCOUNT_ID_JSON}"
else
ACCOUNT_ID="$(cat "${ACCOUNT_ID_JSON}" | get_json_string_value id)"
fi
ACCOUNT_ID="$(cat "${ACCOUNT_KEY_JSON}" | get_json_int_value id)"
if [[ -z "${ACCOUNT_ID}" ]]; then
_exiterr "Unknown error on fetching account information"
fi
Expand Down Expand Up @@ -1562,7 +1565,7 @@ command_help() {
command_env() {
echo "# dehydrated configuration"
load_config
typeset -p CA CERTDIR ALPNCERTDIR CHALLENGETYPE DOMAINS_D DOMAINS_TXT HOOK HOOK_CHAIN RENEW_DAYS ACCOUNT_KEY ACCOUNT_KEY_JSON KEYSIZE WELLKNOWN PRIVATE_KEY_RENEW OPENSSL_CNF CONTACT_EMAIL LOCKFILE
typeset -p CA CERTDIR ALPNCERTDIR CHALLENGETYPE DOMAINS_D DOMAINS_TXT HOOK HOOK_CHAIN RENEW_DAYS ACCOUNT_KEY ACCOUNT_KEY_JSON ACCOUNT_ID_JSON KEYSIZE WELLKNOWN PRIVATE_KEY_RENEW OPENSSL_CNF CONTACT_EMAIL LOCKFILE
}

# Main method (parses script arguments and calls command_* methods)
Expand Down

0 comments on commit 4f358e2

Please sign in to comment.