Modified DNSAPI for PowerDNS to support wildcard certificates

This commit is contained in:
Nils Sandmann 2018-03-21 16:43:42 +01:00
parent 46ac97a3ff
commit af5ff2bb93
No known key found for this signature in database
GPG Key ID: 605B8EC396A1D3B9

View File

@ -88,9 +88,20 @@ set_record() {
_info "Adding record" _info "Adding record"
root=$1 root=$1
full=$2 full=$2
txtvalue=$3 new_challenge=$3
if ! _pdns_rest "PATCH" "/api/v1/servers/$PDNS_ServerId/zones/$root" "{\"rrsets\": [{\"changetype\": \"REPLACE\", \"name\": \"$full.\", \"type\": \"TXT\", \"ttl\": $PDNS_Ttl, \"records\": [{\"name\": \"$full.\", \"type\": \"TXT\", \"content\": \"\\\"$txtvalue\\\"\", \"disabled\": false, \"ttl\": $PDNS_Ttl}]}]}"; then _pdns_rest "GET" "/api/v1/servers/$PDNS_ServerId/zones/$root"
_existing_challenges=($(echo "$response" | _normalizeJson | grep -Po "\"name\":\"$fulldomain\K.*?}]" | grep -Po 'content\":\"\\"\K[^\\]*'))
_record_string=""
_build_record_string $new_challenge
for i in "${_existing_challenges[@]}"
do
_record_string+=", "
_build_record_string $i
done
if ! _pdns_rest "PATCH" "/api/v1/servers/$PDNS_ServerId/zones/$root" "{\"rrsets\": [{\"changetype\": \"REPLACE\", \"name\": \"$full.\", \"type\": \"TXT\", \"ttl\": $PDNS_Ttl, \"records\": [$_record_string]}]}"; then
_err "Set txt record error." _err "Set txt record error."
return 1 return 1
fi fi
@ -185,3 +196,7 @@ _pdns_rest() {
return 0 return 0
} }
_build_record_string() {
_record_string+="{\"content\": \"\\\"$1\\\"\", \"disabled\": false}"
}