update rrset only if existing challenge is found

This commit is contained in:
Michael Braunoeder 2019-09-17 16:00:08 +02:00
parent 68221f62ea
commit b30f94cf82

View File

@ -125,14 +125,19 @@ set_record() {
_build_record_string "$oldchallenge" _build_record_string "$oldchallenge"
done done
if ! _rcode0_rest "PATCH" "/api/v1/acme/zones/$root/rrsets" "[{\"changetype\": \"add\", \"name\": \"$full.\", \"type\": \"TXT\", \"ttl\": $RCODE0_TTL, \"records\": [$_record_string]}]"; then _debug "Challenges: $_existing_challenges"
_err "Set txt record error."
return 1 if [ -z "$_existing_challenges" ]; then
fi if ! _rcode0_rest "PATCH" "/api/v1/acme/zones/$root/rrsets" "[{\"changetype\": \"add\", \"name\": \"$full.\", \"type\": \"TXT\", \"ttl\": $RCODE0_TTL, \"records\": [$_record_string]}]"; then
# try update in case a records exists (need for wildcard certs) _err "Set txt record error."
if ! _rcode0_rest "PATCH" "/api/v1/acme/zones/$root/rrsets" "[{\"changetype\": \"update\", \"name\": \"$full.\", \"type\": \"TXT\", \"ttl\": $RCODE0_TTL, \"records\": [$_record_string]}]"; then return 1
_err "Set txt record error." fi
return 1 else
# try update in case a records exists (need for wildcard certs)
if ! _rcode0_rest "PATCH" "/api/v1/acme/zones/$root/rrsets" "[{\"changetype\": \"update\", \"name\": \"$full.\", \"type\": \"TXT\", \"ttl\": $RCODE0_TTL, \"records\": [$_record_string]}]"; then
_err "Set txt record error."
return 1
fi
fi fi
if ! notify_slaves "$root"; then if ! notify_slaves "$root"; then