My domain is: kirkbymoorside.net
I ran this command: ./dehydrated --cron
against the latest version of dehydrated, downloaded 4 Oct 2020.
and with a line in domains.txt saying:
kirkbymoorside.net *.kirkbymoorside.net
a config file with:
CHALLENGETYPE="dns-01"
HOOK="${BASEDIR}/hook.sh"
CA="https://acme-staging-v02.api.letsencrypt.org/directory"
and a hook script:
#!/usr/bin/env bash
dns-01 challenge
set -e
set -o pipefail
domain="$2"
txt="$4"
echo "Requested $1 for domain $2 and text $4" >> hook.txt
case "$1" in
"deploy_challenge")
echo "About to output stuff for nsupdate" >> hook.txt
echo "server tls.bsr.cloud
update delete $domain.cname.tls.bsr.cloud TXT
update add $domain.cname.tls.bsr.cloud 3600 TXT "$txt"
send
" | nsupdate -k /root/Kletsencrypt.+165+48922.private
echo "Should have done nsupdate" >> hook.txt
;;
"clean_challenge")
;;
"deploy_cert")
;;
"unchanged_cert")
;;
"startup_hook")
;;
"exit_hook")
;;
*)
exit 0
;;
esac
The script wrote diagnostic output to hook.txt:
Requested this_hookscript_is_broken__dehydrated_is_working_fine__please_ignore_unknown_hooks_in_your_script for domain and text
Requested startup_hook for domain and text
Requested this_hookscript_is_broken__dehydrated_is_working_fine__please_ignore_unknown_hooks_in_your_script for domain and text
Requested generate_csr for domain remository.org and text remository.org *.remository.org
Requested unchanged_cert for domain remository.org and text /root/certhelper/certs/remository.org/cert.pem
Requested this_hookscript_is_broken__dehydrated_is_working_fine__please_ignore_unknown_hooks_in_your_script for domain and text
Requested generate_csr for domain kirkbymoorside.net and text kirkbymoorside.net *.kirkbymoorside.net
Requested deploy_challenge for domain kirkbymoorside.net and text NyCxOX2GmUd0asnHbMexEFT3HX1pZb9Vi_o9BDBiEuQ
About to output stuff for nsupdate
Should have done nsupdate
Requested deploy_challenge for domain kirkbymoorside.net and text sYQBM_nUuYEf71LBKsi7wTFqg6S4hiqlZSa9x_uaavk
About to output stuff for nsupdate
Should have done nsupdate
Requested invalid_challenge for domain *.kirkbymoorside.net and text
Requested clean_challenge for domain kirkbymoorside.net and text NyCxOX2GmUd0asnHbMexEFT3HX1pZb9Vi_o9BDBiEuQ
Requested clean_challenge for domain kirkbymoorside.net and text sYQBM_nUuYEf71LBKsi7wTFqg6S4hiqlZSa9x_uaavk
Requested exit_hook for domain Challenge is invalid! (returned: invalid) (result: ["type"] "dns-01"
["status"] "invalid"
["error","type"] "urn:ietf:params:acme:error:unauthorized"
["error","detail"] "Incorrect TXT record "sYQBM_nUuYEf71LBKsi7wTFqg6S4hiqlZSa9x_uaavk" found at _acme-challenge.kirkbymoorside.net"
["error","status"] 403
["error"] {"type":"urn:ietf:params:acme:error:unauthorized","detail":"Incorrect TXT record "sYQBM_nUuYEf71LBKsi7wTFqg6S4hiqlZSa9x_uaavk" found at _acme-challenge.kirkbymoorside.net","status":403}
["url"] "https://acme-staging-v02.api.letsencrypt.org/acme/chall-v3/125685888/iYejvg"
["token"] "6ttaiCOdMcwpxCNdCpltsgJL7o-8uMMPQWlErpEVoE0") and text
PROBLEM: What seems to happen is that the hook is called twice, and the second call overwrites the TXT record with a new value. I'm reasonably confident that the nsupdate works as expected. But the challenge seems to be expecting the first value, and appears to reject the second one. If I create a certificate for the domain alone, without the wild card i.e. domains.txt contains only "kirkbymoorside.net" then the operation works and creates the certificate etc. A subsequent request to obtain a wildcard certificate then works without error. But for a fresh domain that has no previous certificate, I get the failure just described. Probably my misunderstanding, but I don't see where to go with this.