letsencrypt
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| letsencrypt [2019/01/08 20:42] – admin | letsencrypt [2026/08/03 22:06] (current) – admin | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | == new == | + | == new certificate |
| - | < | + | < |
| - | == renew == | + | == add new for nginx == |
| - | < | + | < |
| + | ssl_ciphers | ||
| + | listen 443 ssl http2; | ||
| + | listen [::]:443 ssl http2; | ||
| + | ssl_certificate | ||
| + | ssl_certificate_key | ||
| - | == / | + | == renew for apache == |
| + | < | ||
| + | |||
| + | == renew for nginx == | ||
| + | < | ||
| + | --post-hook "/ | ||
| + | |||
| + | == / | ||
| < | < | ||
| #!/bin/bash | #!/bin/bash | ||
| # | # | ||
| - | / | + | # Pushes a renewed certificate to the Confiared reverse-proxy, |
| + | # IPv4 stop serving the previous one. Called by certbot as renew_hook/ | ||
| + | # --insecure is deliberate: this can run while the certificate of api.confiared.com itself | ||
| + | # is the one being repaired. | ||
| + | |||
| + | if [ ! -f " | ||
| + | then | ||
| + | echo " | ||
| + | echo " | ||
| + | exit 255 | ||
| + | fi | ||
| + | |||
| + | # The api answers 400 + a json explaining why when it refuses a certificate. curl exits 0 on | ||
| + | # a 400, so testing $? alone reports success for a certificate that was in fact rejected: that | ||
| + | # is how a stale certificate stayed on the edges until it expired. Test the http code instead. | ||
| + | # Not -f: -f would throw away the json body, which is the only place the reason is written. | ||
| + | # | ||
| + | # The class of the code is what says whether retrying can ever help: | ||
| + | # | ||
| + | # | ||
| + | # files posted (expired, self signed, private key not matching the certificate...), | ||
| + | # | ||
| + | # a single expired lineage into 100 refusals a day for three months: 06:09 to 22:39 every | ||
| + | # day, which is exactly 1 push plus 99 sleeps of 600s. | ||
| + | # other 000 when curl could not reach the api at all, or a 5xx: that one can heal by itself. | ||
| + | push() | ||
| + | { | ||
| + | local code | ||
| + | code=$(/ | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | case " | ||
| + | 200) | ||
| + | return 0 | ||
| + | ;; | ||
| + | 4??) | ||
| + | # said at the first attempt and not 16h later, and the reason is copied here because the | ||
| + | # .log above is overwritten by the next certificate this host pushes | ||
| + | echo "`date -Is` ${RENEWED_LINEAGE} refused with http ${code}, nothing to retry: $(head -c 300 / | ||
| + | return 2 | ||
| + | ;; | ||
| + | *) | ||
| + | return 1 | ||
| + | ;; | ||
| + | esac | ||
| + | } | ||
| + | |||
| + | push | ||
| + | case $? in | ||
| + | 0) exit 0;; | ||
| + | 2) exit 1;; | ||
| + | esac | ||
| + | |||
| + | # The api did not answer, or answered 5xx. Only that is worth retrying, for ~16h. | ||
| + | for i in {1..99} | ||
| + | do | ||
| + | sleep 600 | ||
| + | push | ||
| + | case $? in | ||
| + | 0) exit 0;; | ||
| + | 2) exit 1;; | ||
| + | esac | ||
| + | done | ||
| + | |||
| + | echo "`date -Is` ${RENEWED_LINEAGE} still not pushed after 99 tries, see / | ||
| + | exit 1 | ||
| </ | </ | ||
| + | |||
| + | == cron == | ||
| + | < | ||
| + | 0 3 * * * sleep ${RANDOM: | ||
letsencrypt.1546980121.txt.gz · Last modified: by admin
