mirror of
https://github.com/dehydrated-io/dehydrated.git
synced 2026-04-10 02:43:34 +02:00
fixed cleanup for invalid challenges
This commit is contained in:
32
dehydrated
32
dehydrated
@@ -553,11 +553,6 @@ http_request() {
|
|||||||
rm -f "${tempcont}"
|
rm -f "${tempcont}"
|
||||||
rm -f "${tempheaders}"
|
rm -f "${tempheaders}"
|
||||||
|
|
||||||
# Wait for hook script to clean the challenge if used
|
|
||||||
if [[ -n "${HOOK}" ]] && [[ "${HOOK_CHAIN}" != "yes" ]] && [[ -n "${challenge_token:+set}" ]]; then
|
|
||||||
"${HOOK}" "clean_challenge" '' "${challenge_token}" "${keyauth}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# remove temporary domains.txt file if used
|
# remove temporary domains.txt file if used
|
||||||
[[ -n "${PARAM_DOMAIN:-}" && -n "${DOMAINS_TXT:-}" ]] && rm "${DOMAINS_TXT}"
|
[[ -n "${PARAM_DOMAIN:-}" && -n "${DOMAINS_TXT:-}" ]] && rm "${DOMAINS_TXT}"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -801,34 +796,33 @@ sign_csr() {
|
|||||||
|
|
||||||
[[ "${CHALLENGETYPE}" = "http-01" ]] && rm -f "${WELLKNOWN}/${challenge_tokens[${idx}]}"
|
[[ "${CHALLENGETYPE}" = "http-01" ]] && rm -f "${WELLKNOWN}/${challenge_tokens[${idx}]}"
|
||||||
|
|
||||||
# Run hook script to clean the challenge token
|
|
||||||
if [[ -n "${HOOK}" ]] && [[ "${HOOK_CHAIN}" != "yes" ]]; then
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
"${HOOK}" "clean_challenge" ${deploy_args[${idx}]}
|
|
||||||
fi
|
|
||||||
idx=$((idx+1))
|
|
||||||
|
|
||||||
if [[ "${reqstatus}" = "valid" ]]; then
|
if [[ "${reqstatus}" = "valid" ]]; then
|
||||||
echo " + Challenge is valid!"
|
echo " + Challenge is valid!"
|
||||||
else
|
else
|
||||||
[[ -n "${HOOK}" ]] && [[ "${HOOK_CHAIN}" != "yes" ]] && "${HOOK}" "invalid_challenge" "${altname}" "${result}"
|
[[ -n "${HOOK}" ]] && [[ "${HOOK_CHAIN}" != "yes" ]] && "${HOOK}" "invalid_challenge" "${altname}" "${result}"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
idx=$((idx+1))
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ ${num_pending_challenges} -ne 0 ]]; then
|
if [[ ${num_pending_challenges} -ne 0 ]]; then
|
||||||
|
echo " + Cleaning challenge tokens..."
|
||||||
|
|
||||||
# Clean challenge tokens using chained hook
|
# Clean challenge tokens using chained hook
|
||||||
[[ -n "${HOOK}" ]] && [[ "${HOOK_CHAIN}" = "yes" ]] && "${HOOK}" "clean_challenge" ${deploy_args[@]}
|
[[ -n "${HOOK}" ]] && [[ "${HOOK_CHAIN}" = "yes" ]] && "${HOOK}" "clean_challenge" ${deploy_args[@]}
|
||||||
|
|
||||||
# Clean remaining challenge tokens if validation has failed
|
# Clean remaining challenge tokens if validation has failed
|
||||||
if [[ "${reqstatus}" != "valid" ]]; then
|
local idx=0
|
||||||
if [[ "${CHALLENGETYPE}" = "http-01" ]] && [[ ${num_pending_challenges} -ne 0 ]]; then
|
while [ ${idx} -lt ${num_pending_challenges} ]; do
|
||||||
while [ ${idx} -lt ${num_pending_challenges} ]; do
|
# Delete challenge file
|
||||||
rm -f "${WELLKNOWN}/${challenge_tokens[${idx}]}"
|
[[ "${CHALLENGETYPE}" = "http-01" ]] && rm -f "${WELLKNOWN}/${challenge_tokens[${idx}]}"
|
||||||
idx=$((idx+1))
|
# Clean challenge token using non-chained hook
|
||||||
done
|
[[ "${CHALLENGETYPE}" = "dns-01" ]] && [[ -n "${HOOK}" ]] && [[ "${HOOK_CHAIN}" != "yes" ]] && "${HOOK}" "clean_challenge" ${deploy_args[${idx}]}
|
||||||
fi
|
idx=$((idx+1))
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ "${reqstatus}" != "valid" ]]; then
|
||||||
|
echo " + Challenge validation has failed :("
|
||||||
_exiterr "Challenge is invalid! (returned: ${reqstatus}) (result: ${result})"
|
_exiterr "Challenge is invalid! (returned: ${reqstatus}) (result: ${result})"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user