mirror of
https://github.com/dehydrated-io/dehydrated.git
synced 2026-01-11 22:30:44 +01:00
Checking certificate status after running dehydrated -c #205
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mavrekh on GitHub (Mar 23, 2017).
Hi,
I have dehydrated running as a cron process with the -c option and I need the process to send out an email whenever a new certificate is successfully obtained: i.e. no "Valid till ... Skipping renew" message, but also no 500 errors from letsencrypt, no issues writing to the .well-known dir, etc. What is the best way the check whether a new certificate has been obtained after running dehydrated? I guess one way would be to grep through the output and look for something like "Done!", but I'd like something more failsafe.
Thanks!
Misha
@txr13 commented on GitHub (Mar 23, 2017):
I personally have a small script for this purpose. It goes through all my certs and compares the SHA-1 hash of the current fullchain.pem to the previous value. If the hash has changed, it fires whatever update is needed for that particular certificate.
You may also be able to use the
deploy_certhook for this purpose, since that is "called once for each certificate that has been produced."@mavrekh commented on GitHub (Mar 23, 2017):
Would you mind sharing the hash comparison script, or at least the relevant parts?
@txr13 commented on GitHub (Mar 23, 2017):
I don't mind at all. I've uploaded it here for your convenience.
Basically, it loops over all certificate directories in
CERTDIR. In each directory, it calculates the current hash for private key and fullchain, checks for the previously-saved hash for the private key and fullchain, and determines whether those files have changed.If a change is found, then we check the certificate directory for a per-certificate override file telling us what actions to take. If found, execute that script. Otherwise, we perform the default actions. Then we fire off an email notifying us of what needs to be done, save the new hash values to the certificate directory, and move on.
Additional points of note:
PRIVATE_KEY_RENEW="yes"and don't have that overridden anywhere), then you can remove the checks for private key hash and the second email completely.@mavrekh commented on GitHub (Mar 24, 2017):
Thank you so much! This is really helpful.
@lukas2511 commented on GitHub (Jul 10, 2017):
I'd recommend using the
deploy_certhook for this like @txr13 already mentioned.@mavrekh commented on GitHub (Jul 11, 2017):
Yes, I ended up implementing a deploy_cert hook and it works great. Sorry for not closing this earlier, and thanks so much for your help.