From 2684f5c3924a49e5a35a0f5e5168801283b0b1a7 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Fri, 13 Mar 2015 15:51:50 -0500 Subject: [PATCH] Make date command work with both Linux and FreeBSD --- testssl.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/testssl.sh b/testssl.sh index a0f468f..d66656e 100755 --- a/testssl.sh +++ b/testssl.sh @@ -1177,8 +1177,16 @@ server_defaults() { pr_litered "expires < $DAYS2WARN2 days!" fi fi - enddate=$(date --date="$($OPENSSL x509 -in $HOSTCERT -noout -enddate | cut -d= -f 2)" +"%F %H:%M %z") - startdate=$(date --date="$($OPENSSL x509 -in $HOSTCERT -noout -startdate | cut -d= -f 2)" +"%F %H:%M") + case $(uname -s) in + Linux) + enddate=$(date --date="$($OPENSSL x509 -in $HOSTCERT -noout -enddate | cut -d= -f 2)" +"%F %H:%M %z") + startdate=$(date --date="$($OPENSSL x509 -in $HOSTCERT -noout -startdate | cut -d= -f 2)" +"%F %H:%M") + ;; + FreeBSD) + enddate=$(date -j -f "%b %d %T %Y %Z" "$($OPENSSL x509 -in $HOSTCERT -noout -enddate | cut -d= -f 2)" +"%F %H:%M %z") + startdate=$(date -j -f "%b %d %T %Y %Z" "$($OPENSSL x509 -in $HOSTCERT -noout -startdate | cut -d= -f 2)" +"%F %H:%M") + ;; + esac outln " ($startdate --> $enddate)" savedir=$(pwd); cd $TEMPDIR