This is a continuation of my previous topics on this matter: Caddy vs inotify and Caddy vs inotify — 2
I’m using Caddy for obtaining certificates for all domains I use, and I’m monitoring /var/lib/caddy/certificates/acme-v02.api.letsencrypt.org-directory/example.com/example.com.json
file via the systemd.path
mechanism to trigger actions on a domain certificate renewal for non-Caddy daemons:
# /etc/systemd/system/tls@.path
[Unit]
Description=Caddy TLS hook - %i
Before=caddy.service
[Path]
PathChanged=/var/lib/caddy/certificates/acme-v02.api.letsencrypt.org-directory/%i/%i.json
[Install]
WantedBy=multi-user.target
# /etc/systemd/system/tls@.service
[Unit]
Description=Caddy TLS hook - %i
AssertPathExists=/var/lib/caddy/certificates/acme-v02.api.letsencrypt.org-directory/%i/%i.crt
AssertPathExists=/var/lib/caddy/certificates/acme-v02.api.letsencrypt.org-directory/%i/%i.key
[Service]
Type=oneshot
Environment="TLS_DOMAIN=%i" "TLS_CERT=/var/lib/caddy/certificates/acme-v02.api.letsencrypt.org-directory/%i/%i.crt" "TLS_KEY=/var/lib/caddy/certificates/acme-v02.api.letsencrypt.org-directory/%i/%i.key"
ExecStart=/var/lib/caddy/tls-hooks/%i
After a recent Caddy upgrade, 2.7.6-1 -> 2.8.4-1
, I’ve noticed that the .json
file is updated every day (?) because there’s new piece of info in it, renewal_info
, which is, as I think, a consequence of this change.
This means the .path
unit is now triggered much more often than it should be. So I have to watch either .crt
or .key
file instead.
The question is which one? Is it .crt
that gets updated after .key
, or it is .key
that gets updated after .crt
? Is .key
updated each time .crt
is updated or only on some occasions? It is not clear from the file timestamps as they seem to be identical, and I was unable to find this information in the code.
Thank you.