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:
Aaron Roydhouse
2016-12-22 03:58:48 -05:00
committed by Lukas Schauer
parent 7f30826a6d
commit 636fa1a559
+2
View File
@@ -520,6 +520,7 @@ sign_csr() {
# Respond to challenges # Respond to challenges
reqstatus="valid" reqstatus="valid"
idx=0 idx=0
if [ ${#challenge_altnames[@]} -ne 0 ]; then
for altname in "${challenge_altnames[@]:0}"; do for altname in "${challenge_altnames[@]:0}"; do
challenge_token="${challenge_tokens[${idx}]}" challenge_token="${challenge_tokens[${idx}]}"
keyauth="${keyauths[${idx}]}" keyauth="${keyauths[${idx}]}"
@@ -555,6 +556,7 @@ sign_csr() {
[[ -n "${HOOK}" ]] && [[ "${HOOK_CHAIN}" != "yes" ]] && "${HOOK}" "invalid_challenge" "${altname}" "${result}" [[ -n "${HOOK}" ]] && [[ "${HOOK_CHAIN}" != "yes" ]] && "${HOOK}" "invalid_challenge" "${altname}" "${result}"
fi fi
done 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