Hallo zusammen, ich bin dabei von getssl auf certbot zu wechseln um mir ein Wildcard-Zertifikat zu erzeugen.
Um mir ein Wildcard-Zertifikat zu erzeugen brauche ich einen eigenen DNS-Server. Ich setze hier bind9 ein. Wenn ich ein Wildcard-Zertifikat erzeugen lasse, gebe ich zwei Pfade zu selbst geschriebenen Skripten mit. Dabei wird im ersten Skript ein neuer _acme_challange TXT record mit letsencrypt token hinzugefügt. Nach der Validierung durch letsencrypt wird im zweiten Skript meine Zone wieder bereinigt.
Meine Aufruf von certbot sieht wie folgt aus.
1 2 3 4 5 6 7 8 9 | certbot certonly -n \ --manual-public-ip-logging-ok \ --server https://acme-v02.api.letsencrypt.org/directory \ --agree-tos \ --manual \ --preferred-challenges dns \ --manual-auth-hook /etc/letsencrypt/scripts/dns-auth.sh \ --manual-cleanup-hook /etc/letsencrypt/scripts/dns-clean.sh \ --domain "*.cryptic.systems" |
Skript: *dns-auth.sh*
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | root@pontos:~# cat /etc/letsencrypt/scripts/dns-auth.sh #!/bin/bash BASE=$(dirname $0) if [ -z "$CERTBOT_DOMAIN" ] || [ -z "$CERTBOT_VALIDATION" ]; then echo "EMPTY DOMAIN OR VALIDATION" exit -1 fi HOST="_acme-challenge" /usr/bin/nsupdate -k "${BASE}/Kletsencrypt.+157+53036.key" << EOM update add ${HOST}.${CERTBOT_DOMAIN} 300 TXT "${CERTBOT_VALIDATION}" send EOM echo "FINISHED" |
Skript: *dns-clean.sh*.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | root@pontos:~# cat /etc/letsencrypt/scripts/dns-cleanup.sh #!/bin/bash BASE=$(dirname $0) if [ -z "$CERTBOT_DOMAIN" ] || [ -z "$CERTBOT_VALIDATION" ]; then echo "EMPTY DOMAIN OR VALIDATION" exit -1 fi HOST="_acme-challenge" /usr/bin/nsupdate -k "${BASE}/Kletsencrypt.+157+53036.key" << EOM update delete ${HOST}.${CERTBOT_DOMAIN} TXT send EOM echo "FINISHED" |
Jetzt wird auch ein Zertifikat für *.cryptic.systems erzeugt. Allerdings möchte ich cryptic.systems als Domain auch im Zertifikat hinterlegt haben. Nun füge ich die Domain beim Aufruf von Certbot hinzu, nachdem ich alle Zertifikate und Konfigurationen für die Domain cryptic.systems unter /etc/letsencrypt gelöscht habe.
1 2 3 4 5 6 7 8 9 10 | certbot certonly -n \ --manual-public-ip-logging-ok \ --server https://acme-v02.api.letsencrypt.org/directory \ --agree-tos \ --manual \ --preferred-challenges dns \ --manual-auth-hook /etc/letsencrypt/scripts/dns-auth.sh \ --manual-cleanup-hook /etc/letsencrypt/scripts/dns-cleanup.sh \ --domain "*.cryptic.systems" \ --domain "cryptic.systems" |
Das hat soweit auch funktioniert. Siehe Zertifikat von cryptic.systems. Jetzt kommt der Clou an der Sache. Ich möchte nun einem systemd timer konfigurieren, der certbot jeden Abend aufruft um meine Zertifikate 30 Tage vor dem Ablauf zu erneuern.
Dazu rufe ich certbot renew
und erhalte folgende Ausgabe.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | root@pontos:~# certbot renew Saving debug log to /var/log/letsencrypt/letsencrypt.log ------------------------------------------------------------------------------- Processing /etc/letsencrypt/renewal/cryptic.systems.conf ------------------------------------------------------------------------------- Cert not yet due for renewal Plugins selected: Authenticator manual, Installer None ------------------------------------------------------------------------------- The following certs are not due for renewal yet: /etc/letsencrypt/live/cryptic.systems/fullchain.pem expires on 2019-01-18 (skipped) No renewals were attempted. ------------------------------------------------------------------------------- |
Nun kann ich so nicht testen, ob mein Workflow zum aktualisieren der Zertifikate einwandfrei funktioniert. Nun habe ich versucht das mit --dry-run
zu testen und erhalte folgende Rückmeldung von certbot.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | root@pontos:~# certbot renew --dry-run Saving debug log to /var/log/letsencrypt/letsencrypt.log ------------------------------------------------------------------------------- Processing /etc/letsencrypt/renewal/cryptic.systems.conf ------------------------------------------------------------------------------- Cert not due for renewal, but simulating renewal for dry run Plugins selected: Authenticator manual, Installer None Running pre-hook command: /etc/letsencrypt/renewal-hooks/pre/docker-nginx.sh Error output from docker-nginx.sh: Network cs_network is external, skipping Network mp_network is external, skipping Network dj_network is external, skipping Running pre-hook command: /etc/letsencrypt/renewal-hooks/pre/dovecot.sh Running pre-hook command: /etc/letsencrypt/renewal-hooks/pre/nginx.sh Running pre-hook command: /etc/letsencrypt/renewal-hooks/pre/postfix.sh Running pre-hook command: /etc/letsencrypt/renewal-hooks/pre/prosody.sh Renewing an existing certificate Performing the following challenges: dns-01 challenge for cryptic.systems dns-01 challenge for cryptic.systems Output from dns-auth.sh: FINISHED Output from dns-auth.sh: FINISHED Waiting for verification... Cleaning up challenges Attempting to renew cert (cryptic.systems) from /etc/letsencrypt/renewal/cryptic.systems.conf produced an unexpected error: Failed authorization procedure. cryptic.systems (dns-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: Incorrect TXT record "-XhwQ-85C3v0RQbMlNTXwgYcjh_avGk-hh-QufQBFjY" found at _acme-challenge.cryptic.systems. Skipping. ------------------------------------------------------------------------------- The following certs could not be renewed: /etc/letsencrypt/live/cryptic.systems/fullchain.pem (failure) ------------------------------------------------------------------------------- ** DRY RUN: simulating 'certbot renew' close to cert expiry ** (The test certificates below have not been saved.) The following certs could not be renewed: /etc/letsencrypt/live/cryptic.systems/fullchain.pem (failure) ** DRY RUN: simulating 'certbot renew' close to cert expiry ** (The test certificates above have not been saved.) ------------------------------------------------------------------------------- Running post-hook command: /etc/letsencrypt/renewal-hooks/post/docker-nginx.sh Error output from docker-nginx.sh: Network cs_network is external, skipping Network mp_network is external, skipping Network dj_network is external, skipping Running post-hook command: /etc/letsencrypt/renewal-hooks/post/dovecot.sh Running post-hook command: /etc/letsencrypt/renewal-hooks/post/nginx.sh Running post-hook command: /etc/letsencrypt/renewal-hooks/post/postfix.sh Running post-hook command: /etc/letsencrypt/renewal-hooks/post/prosody.sh 1 renew failure(s), 0 parse failure(s) IMPORTANT NOTES: - The following errors were reported by the server: Domain: cryptic.systems Type: unauthorized Detail: Incorrect TXT record "-XhwQ-85C3v0RQbMlNTXwgYcjh_avGk-hh-QufQBFjY" found at _acme-challenge.cryptic.systems To fix these errors, please make sure that your domain name was entered correctly and the DNS A/AAAA record(s) for that domain contain(s) the right IP address. |
Im Ganzen verstehe ich die Meldung. Mein Skript dns-auth.sh wird für jede Domain nacheinander aufgerufen. Anschließend erfolgt die Validierung und die Ausführung des dns-cleanup.sh Skript. Da certbot dns-auth.sh nacheinander für jede Domain ausführt bleibt nur der Token der letzten Domain in der Zone vorhanden und letsencrypt kann nur eine Domain validieren. Wie kann ich certbot konfigurieren, dass die Domains nacheinander validiert werden sollen, so wie certbot es gemacht hat beim ersten erzeugen der Zertifikate?
Hat jemand eine Ahnung wie man das am besten umsetzt?
Viele Grüße Volker