Unverified Commit af5ff2bb authored by Nils Sandmann's avatar Nils Sandmann
Browse files

Modified DNSAPI for PowerDNS to support wildcard certificates

parent 46ac97a3
...@@ -88,9 +88,20 @@ set_record() { ...@@ -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() { ...@@ -185,3 +196,7 @@ _pdns_rest() {
return 0 return 0
} }
_build_record_string() {
_record_string+="{\"content\": \"\\\"$1\\\"\", \"disabled\": false}"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment