CA delegation: name-constrained intermediates, root rotation, ACME node certificates
New roots carry path length 1. `rollcall ca intermediate` signs a CSR (or a generated key) as an intermediate limited to the permitted domains and address ranges; a root with path length 0 refuses and `rollcall ca rotate` replaces it. deploy/tags/acme-cert.yaml gets a node certificate from an ACME server under such an intermediate and renews it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bcbb07721b
commit
77894b7d57
6 files changed
+311
-2
No files matched your search
@@ -0,0 +1,47 @@
|
||||
#cloud-config
|
||||
# Rollcall tag fragment: a TLS certificate for the node from the site's ACME CA
|
||||
# (an ACME server under a Rollcall intermediate, see README "Delegation"), renewed automatically.
|
||||
# Register with: rollcall tags add acme-cert -cloud-config deploy/tags/acme-cert.yaml
|
||||
# Edit the two lines in /etc/rollcall-acme.conf for your site. Deployments already trust the
|
||||
# Rollcall CA (cloud-init ca_certs), so certbot can talk to the ACME server over TLS.
|
||||
# Result: /etc/letsencrypt/live/<fqdn>/{fullchain,privkey}.pem; log /var/log/rollcall-acme.log.
|
||||
write_files:
|
||||
- path: /etc/rollcall-acme.conf
|
||||
permissions: "0644"
|
||||
content: |
|
||||
ACME_DIRECTORY=https://acme.int.mynodes.xyz/acme/rollcall/directory
|
||||
DOMAIN=int.mynodes.xyz
|
||||
- path: /usr/local/sbin/rollcall-acme-cert
|
||||
permissions: "0755"
|
||||
content: |
|
||||
#!/bin/sh
|
||||
# Gets <host>.<DOMAIN> from the ACME server (http-01 on port 80) and sets up renewal.
|
||||
set -eu
|
||||
exec >>/var/log/rollcall-acme.log 2>&1
|
||||
. /etc/rollcall-acme.conf
|
||||
. /etc/os-release
|
||||
fqdn="$(hostname -s).$DOMAIN"
|
||||
echo "== $(date -Is) certificate for $fqdn from $ACME_DIRECTORY"
|
||||
case "$ID" in
|
||||
debian|ubuntu) bundle=/etc/ssl/certs/ca-certificates.crt
|
||||
command -v certbot >/dev/null || { apt-get update; DEBIAN_FRONTEND=noninteractive apt-get install -y certbot; } ;;
|
||||
rocky|almalinux|centos|rhel) bundle=/etc/pki/tls/certs/ca-bundle.crt
|
||||
command -v certbot >/dev/null || { dnf -y install epel-release || true; dnf -y install certbot; } ;;
|
||||
*) echo "unsupported distro $ID"; exit 1 ;;
|
||||
esac
|
||||
export REQUESTS_CA_BUNDLE="$bundle"
|
||||
# renewals run from certbot's own timer; it needs the same trust and server
|
||||
for unit in certbot.service certbot-renew.service; do
|
||||
mkdir -p "/etc/systemd/system/$unit.d"
|
||||
printf '[Service]\nEnvironment=REQUESTS_CA_BUNDLE=%s\n' "$bundle" > "/etc/systemd/system/$unit.d/rollcall-acme.conf"
|
||||
done
|
||||
systemctl daemon-reload
|
||||
certbot certonly --standalone --non-interactive --agree-tos --register-unsafely-without-email \
|
||||
--server "$ACME_DIRECTORY" --cert-name "$fqdn" -d "$fqdn" --keep-until-expiring
|
||||
# short-lived certificates: renew when a third of the lifetime is left, not 30 days before
|
||||
sed -i 's/^#\? *renew_before_expiry.*/renew_before_expiry = 2 days/' "/etc/letsencrypt/renewal/$fqdn.conf"
|
||||
grep -q '^renew_before_expiry' "/etc/letsencrypt/renewal/$fqdn.conf" || echo 'renew_before_expiry = 2 days' >> "/etc/letsencrypt/renewal/$fqdn.conf"
|
||||
systemctl enable --now certbot.timer 2>/dev/null || systemctl enable --now certbot-renew.timer
|
||||
openssl x509 -in "/etc/letsencrypt/live/$fqdn/cert.pem" -noout -subject -issuer -enddate
|
||||
runcmd:
|
||||
- [/usr/local/sbin/rollcall-acme-cert]
|
||||
Reference in new issue
Block a user