I'm having trouble getting the below script to pass when I test against servers. Here is the details from the test:
Script output values are not defined or improperly defined.
Output: =====================================================
bash /home/snmpmon/./APM_2114941437.pl arg1
Retrieving data for arg1
arg1 issuer= /CN=ACCVRAIZ1/OU=PKIACCV/O=ACCV/C=ES
notBefore=May 5 09:37:37 2011 GMT
notAfter=Dec 31 09:37:37 2030 GMT
Signature Algorithm: sha1WithRSAEncryption
Will expire in 4143 days
Any idea what what I need to add or change to define the script output?
#!/bin/bash
getssl()
{
echo -n "$SITE "
SITE="$SITE:443"
echo | openssl s_client -connect $SITE 2> /dev/null | openssl x509 -noout -issuer -dates -in /etc/pki/tls/certs/ca-bundle.crt ; echo | openssl s_client -connect $SITE 2> /dev/null | openssl x509 -text -in /etc/pki/tls/certs/ca-bundle.crt | grep "Signature Algorithm:" | sort -u
expire=`date +%s -d "$(echo | openssl s_client -connect $SITE 2> /dev/null | openssl x509 -noout -enddate -in /etc/pki/tls/certs/ca-bundle.crt | cut -d"=" -f2-)"`
#echo $expire
today=`date +%s`
#echo $today
timepass=$(( ( $expire - $today ) / 86400 + 1 ))
if [[ $timepass -gt 60 ]]
then
echo "Will expire in $timepass days"
elif [[ $timepass -gt 0 ]]
then
echo "Will Expire within next $timepass days"
elif [[ $timepass -eq 0 ]]
then
echo "CERTIFICATE EXPIRES TODAY"
else
echo "CERTIFICATE HAS EXPIRED"
fi
#echo $timepass
}
for SITE in $*
#for SITE in $(< /home/bcaimi/servers)
do
echo "Retrieving data for $SITE"
getssl
echo "===================="
done