pr:le-dns-delegate
no way to compare when less than two revisions
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
— | pr:le-dns-delegate [2023/05/03 22:25] (aktuell) – angelegt martok | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | ====== Delegating Let's Encrypt dns-01 to a dedicated zone ====== | ||
+ | |||
+ | ===== Problem ===== | ||
+ | |||
+ | Let's Encryt offers [[https:// | ||
+ | |||
+ | ==== Concept ==== | ||
+ | |||
+ | Instead of responding to a challenge in individual zones, create one " | ||
+ | |||
+ | For this example, we'll use the following setup: | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * [[https:// | ||
+ | |||
+ | ==== Setup ==== | ||
+ | |||
+ | === Domain Setup === | ||
+ | |||
+ | First, we need the zone that will handle all our ACME challenges. This is a regular [[https:// | ||
+ | |||
+ | <file - acme.example.com.zone> | ||
+ | $ORIGIN . | ||
+ | $TTL 3600 ; 1 hour | ||
+ | acme.example.com | ||
+ | 2023040100 ; serial | ||
+ | 3600 ; refresh (1 hour) | ||
+ | 3600 ; retry (1 hour) | ||
+ | 86400 ; expire (1 day) | ||
+ | 3600 ; minimum (1 hour) | ||
+ | ) | ||
+ | NS ns1.example.com. | ||
+ | NS ns2.example.com. | ||
+ | MX 0 . | ||
+ | TXT " | ||
+ | CAA 0 issue " | ||
+ | CAA 0 issuewild " | ||
+ | </ | ||
+ | |||
+ | Next, we'll need some TSIG keys used for the '' | ||
+ | |||
+ | <file bash> | ||
+ | tsig-keygen -a hmac-sha512 client1.example.acme > Kexample.client1._acme-challenge.key | ||
+ | tsig-keygen -a hmac-sha512 client2.test.acme > Ktest.client2._acme-challenge.key | ||
+ | cat *._acme-challenge.key >> / | ||
+ | </ | ||
+ | |||
+ | Now we can use those to enable updates to the ACME delegate zone. The general pattern will be that each certificate target will be prepended as a subdomain to the delegate, so it becomes '' | ||
+ | |||
+ | <file - acme.example.com.cfg> | ||
+ | zone " | ||
+ | type master; | ||
+ | file "/ | ||
+ | |||
+ | update-policy { | ||
+ | grant client1.example.acme. subdomain client1.example.acme.example.com. TXT; | ||
+ | grant client2.test.acme. subdomain client2.test.acme.example.com. TXT; | ||
+ | }; | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | On the side of the client domains, we need to tell ACME that it needs to use these zones for challenges. We do that by setting '' | ||
+ | |||
+ | <file - client1.example.zone> | ||
+ | $ORIGIN client1.example. | ||
+ | _acme-challenge | ||
+ | $ORIGIN client2.example. | ||
+ | _acme-challenge | ||
+ | </ | ||
+ | |||
+ | Note that we point them all to the same location defined by the SOA+delegate-pattern explained above. In the second case, we even point a different domain to the same target. This could be used to share key material between multiple domains owned by the same entity. | ||
+ | |||
+ | Next, we can tell dehydrated to use this setup for challenges. | ||
+ | |||
+ | == Dehydrated Setup == | ||
+ | |||
+ | The '' | ||
+ | |||
+ | |||
+ | <file bash / | ||
+ | # | ||
+ | |||
+ | # | ||
+ | # Deployment script for DNS challenge using nsupdate | ||
+ | # | ||
+ | # Arguments: hook ACTION DOMAIN CTOKEN VTOKEN | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | |||
+ | set -e | ||
+ | set -u | ||
+ | set -o pipefail | ||
+ | |||
+ | KEYDIR="/ | ||
+ | |||
+ | SOA=" | ||
+ | SOALIST=" | ||
+ | |||
+ | while [[ " | ||
+ | SOA=" | ||
+ | SOALIST=" | ||
+ | done | ||
+ | |||
+ | for SOA in ${SOALIST}; do | ||
+ | KEYFILE=" | ||
+ | if [ -r " | ||
+ | if [ -L " | ||
+ | KEYFILE=" | ||
+ | SOA=" | ||
+ | SOA=" | ||
+ | fi | ||
+ | break | ||
+ | fi | ||
+ | unset KEYFILE | ||
+ | done | ||
+ | |||
+ | KEYFILE=" | ||
+ | NSUPDATE=" | ||
+ | DNSSERVER=" | ||
+ | ZONE=" | ||
+ | TTL=600 | ||
+ | |||
+ | CHALLENGE=$(printf " | ||
+ | |||
+ | case " | ||
+ | deploy_challenge) | ||
+ | printf " | ||
+ | ;; | ||
+ | clean_challenge) | ||
+ | printf " | ||
+ | ;; | ||
+ | deploy_cert) | ||
+ | # optional: | ||
+ | # / | ||
+ | ;; | ||
+ | unchanged_cert) | ||
+ | # do nothing for now | ||
+ | ;; | ||
+ | startup_hook) | ||
+ | # do nothing for now | ||
+ | ;; | ||
+ | exit_hook) | ||
+ | # do nothing for now | ||
+ | ;; | ||
+ | esac | ||
+ | |||
+ | exit 0 | ||
+ | </ | ||
+ | |||
+ | This script will take the incoming primary domain name requested for the new certificate and try to locate the TSIG key to use with it. These are expected to be present in the path defined by '' | ||
+ | |||
+ | In the case of multiple domains using the same key, the actual file is named for the SOA-root as defined above and other domains sharing it are symlinks to this file. In the example: | ||
+ | |||
+ | <file bash> | ||
+ | cp Kexample.client1._acme-challenge.key client1.example.acme.conf | ||
+ | ln -s client2.example.acme.conf client1.example.acme.conf | ||
+ | </ | ||
+ | |||
+ | Examples: | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | The '' | ||
+ | |||
+ | |||
+ | ===== Summary ===== | ||
+ | |||
+ | This is everything required to run dehydrated in a way that doesn' | ||
+ | |||
+ | If something doesn' | ||
+ | |||
+ | |||
+ | ==== Resources ==== | ||
+ | |||
+ | * [[https:// | ||
+ | * [[https:// | ||
pr/le-dns-delegate.txt · Zuletzt geändert: 2023/05/03 22:25 von martok