Better date support for BSD/GNU

Signed-off-by: Eric F Crist <ecrist@secure-computing.net>
This commit is contained in:
Eric F Crist 2019-01-31 23:17:26 -06:00
parent 566e7c38f6
commit 7c705f3fb2

View File

@ -1010,9 +1010,17 @@ at: $crt_in"
"$EASYRSA_OPENSSL" x509 -in "$crt_in" -noout -enddate |
sed 's/^notAfter=//'
)
expire_date=$(date -d "$expire_date" +%s)
allow_renew_date=$(date -d "+${EASYRSA_CERT_RENEW}day" +%s)
case $(uname) in
"Darwin"|*"BSD")
expire_date=$(date -j -f '%b %d %T %Y %Z' "$expire_date" +%s)
allow_renew_date=$(date -j -v"+${EASYRSA_CERT_RENEW}d" +%s)
;;
*)
# This works on Windows, too, since uname doesn't exist and this is catch-all
expire_date=$(date -d "$expire_date" +%s)
allow_renew_date=$(date -d "+${EASYRSA_CERT_RENEW}day" +%s)
;;
esac
[ "$expire_date" -lt "$allow_renew_date" ] || die "\
Certificate expires in more than $EASYRSA_CERT_RENEW days.