mirror of
https://github.com/dehydrated-io/dehydrated.git
synced 2026-07-09 14:42:47 +02:00
Test for case when challenge_altnames is empty (#321)
When all names in a cert have already been validated, the challenge_altnames array will be empty, causes an error in later code. This patch adds a test to handle that case.
This commit is contained in:
committed by
Lukas Schauer
parent
7f30826a6d
commit
636fa1a559
+36
-34
@@ -520,41 +520,43 @@ sign_csr() {
|
|||||||
# Respond to challenges
|
# Respond to challenges
|
||||||
reqstatus="valid"
|
reqstatus="valid"
|
||||||
idx=0
|
idx=0
|
||||||
for altname in "${challenge_altnames[@]:0}"; do
|
if [ ${#challenge_altnames[@]} -ne 0 ]; then
|
||||||
challenge_token="${challenge_tokens[${idx}]}"
|
for altname in "${challenge_altnames[@]:0}"; do
|
||||||
keyauth="${keyauths[${idx}]}"
|
challenge_token="${challenge_tokens[${idx}]}"
|
||||||
|
keyauth="${keyauths[${idx}]}"
|
||||||
# Wait for hook script to deploy the challenge if used
|
|
||||||
# shellcheck disable=SC2086
|
# Wait for hook script to deploy the challenge if used
|
||||||
[[ -n "${HOOK}" ]] && [[ "${HOOK_CHAIN}" != "yes" ]] && "${HOOK}" "deploy_challenge" ${deploy_args[${idx}]}
|
|
||||||
|
|
||||||
# Ask the acme-server to verify our challenge and wait until it is no longer pending
|
|
||||||
echo " + Responding to challenge for ${altname}..."
|
|
||||||
result="$(signed_request "${challenge_uris[${idx}]}" '{"resource": "challenge", "keyAuthorization": "'"${keyauth}"'"}' | clean_json)"
|
|
||||||
|
|
||||||
reqstatus="$(printf '%s\n' "${result}" | get_json_string_value status)"
|
|
||||||
|
|
||||||
while [[ "${reqstatus}" = "pending" ]]; do
|
|
||||||
sleep 1
|
|
||||||
result="$(http_request get "${challenge_uris[${idx}]}")"
|
|
||||||
reqstatus="$(printf '%s\n' "${result}" | get_json_string_value status)"
|
|
||||||
done
|
|
||||||
|
|
||||||
[[ "${CHALLENGETYPE}" = "http-01" ]] && rm -f "${WELLKNOWN}/${challenge_token}"
|
|
||||||
|
|
||||||
# Wait for hook script to clean the challenge if used
|
|
||||||
if [[ -n "${HOOK}" ]] && [[ "${HOOK_CHAIN}" != "yes" ]] && [[ -n "${challenge_token}" ]]; then
|
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
"${HOOK}" "clean_challenge" ${deploy_args[${idx}]}
|
[[ -n "${HOOK}" ]] && [[ "${HOOK_CHAIN}" != "yes" ]] && "${HOOK}" "deploy_challenge" ${deploy_args[${idx}]}
|
||||||
fi
|
|
||||||
idx=$((idx+1))
|
# Ask the acme-server to verify our challenge and wait until it is no longer pending
|
||||||
|
echo " + Responding to challenge for ${altname}..."
|
||||||
if [[ "${reqstatus}" = "valid" ]]; then
|
result="$(signed_request "${challenge_uris[${idx}]}" '{"resource": "challenge", "keyAuthorization": "'"${keyauth}"'"}' | clean_json)"
|
||||||
echo " + Challenge is valid!"
|
|
||||||
else
|
reqstatus="$(printf '%s\n' "${result}" | get_json_string_value status)"
|
||||||
[[ -n "${HOOK}" ]] && [[ "${HOOK_CHAIN}" != "yes" ]] && "${HOOK}" "invalid_challenge" "${altname}" "${result}"
|
|
||||||
fi
|
while [[ "${reqstatus}" = "pending" ]]; do
|
||||||
done
|
sleep 1
|
||||||
|
result="$(http_request get "${challenge_uris[${idx}]}")"
|
||||||
|
reqstatus="$(printf '%s\n' "${result}" | get_json_string_value status)"
|
||||||
|
done
|
||||||
|
|
||||||
|
[[ "${CHALLENGETYPE}" = "http-01" ]] && rm -f "${WELLKNOWN}/${challenge_token}"
|
||||||
|
|
||||||
|
# Wait for hook script to clean the challenge if used
|
||||||
|
if [[ -n "${HOOK}" ]] && [[ "${HOOK_CHAIN}" != "yes" ]] && [[ -n "${challenge_token}" ]]; then
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
"${HOOK}" "clean_challenge" ${deploy_args[${idx}]}
|
||||||
|
fi
|
||||||
|
idx=$((idx+1))
|
||||||
|
|
||||||
|
if [[ "${reqstatus}" = "valid" ]]; then
|
||||||
|
echo " + Challenge is valid!"
|
||||||
|
else
|
||||||
|
[[ -n "${HOOK}" ]] && [[ "${HOOK_CHAIN}" != "yes" ]] && "${HOOK}" "invalid_challenge" "${altname}" "${result}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# Wait for hook script to clean the challenges if used
|
# Wait for hook script to clean the challenges if used
|
||||||
# shellcheck disable=SC2068
|
# shellcheck disable=SC2068
|
||||||
|
|||||||
Reference in New Issue
Block a user