Révision 793b75b9
squash! [ssl-certificate-expiry] Add asynchronous update via cron
revert local
| plugins/ssl/ssl-certificate-expiry | ||
|---|---|---|
| 1 | 1 |
#!/bin/sh -u |
| 2 | 2 |
# -*- sh -*- |
| 3 |
# shellcheck disable=SC2039 |
|
| 3 | 4 |
|
| 4 | 5 |
: << =cut |
| 5 | 6 |
|
| ... | ... | |
| 73 | 74 |
# Read data including a certificate from stdin and output the (fractional) number of days left |
| 74 | 75 |
# until the expiry of this certificate. The output is empty if parsing failed. |
| 75 | 76 |
parse_valid_days_from_certificate() {
|
| 77 |
local input_data |
|
| 78 |
local valid_until_string |
|
| 79 |
local valid_until_epoch |
|
| 80 |
local now_epoch |
|
| 81 |
local input_data |
|
| 76 | 82 |
input_data=$(cat) |
| 77 | 83 |
if echo "$input_data" | grep -q -- "-----BEGIN CERTIFICATE-----"; then |
| 78 | 84 |
valid_until_string=$(echo "$input_data" | openssl x509 -noout -enddate \ |
| ... | ... | |
| 90 | 96 |
|
| 91 | 97 |
|
| 92 | 98 |
print_expire_days() {
|
| 93 |
host="$1" |
|
| 94 |
port="$2" |
|
| 99 |
local host="$1"
|
|
| 100 |
local port="$2"
|
|
| 95 | 101 |
|
| 96 | 102 |
# Wrap IPv6 addresses in square brackets |
| 97 | 103 |
echo "$host" | grep -q ':' && host="[$host]" |
Formats disponibles : Unified diff