ALL

For reading and verification only. You may not copy, use, modify or redistribute this code. Full notice on the main page.

tunnel/deploy/all-tunnel-certbot.service

SHA-256: 4a6cec2694261e6f80a01db9f4c739d8b63e2dfdbbfb8d3fe584fa4f961b9928
25 lines · 1707 bytes · View on GitHub

1# Renews the node's OWN certificate (the name the devices connect to, ALPN all-tunnel/2) with certbot, HTTP-01 through the webroot the node serves on :80.
2# Devices' names never come here: their certificates are issued on the devices over DNS-01 (the design plan, section 4).
3#
4# It fails LOUDLY, on purpose, and in three places a silent failure would hide:
5# certbot renew exits non-zero when a renewal was due and failed (no `|| true`, no `-q` that swallows the reason)
6# --deploy-hook all-tunnel-cert-hook: checks the new pair, installs it, reloads the node, and fails when the node did not take it
7# ExecStartPost all-tunnel-cert-check: fails when the certificate in service has less than ALL_TUNNEL_CERT_MIN_DAYS left, which is what
8# a renewal that "succeeded" but never replaced anything looks like
9# and any failure runs all-tunnel-certbot-failed.service (a critical journal line, a marker file `tunnel_deploy.py status` reports). The days are the
10# first alert of policy.monitoring.node_cert_alert_days (14): the site monitor mails the owner at 14 and at 5 days anyway, this is the node's own voice.
11[Unit]
12Description=Renew the ALL tunnel node's own certificate (certbot, HTTP-01 webroot)
13Wants=network-online.target
14After=network-online.target
15OnFailure=all-tunnel-certbot-failed.service
16
17[Service]
18Type=oneshot
19EnvironmentFile=/etc/all-tunnel/env
20Environment=ALL_TUNNEL_CERT_MIN_DAYS=14
21ExecStart=/usr/bin/certbot renew --non-interactive --no-random-sleep-on-renew --deploy-hook /usr/local/sbin/all-tunnel-cert-hook
22ExecStartPost=/usr/local/sbin/all-tunnel-cert-check
23TimeoutStartSec=15min
24PrivateTmp=yes
25NoNewPrivileges=yes