Remote cert tests
#!/bin/bash

#if [ "$#" -ne 1 ]; then
if [ "$#" -lt 1 ]; then
 echo "must include at least hostname/ip" 
 echo "syntax:"
 echo "test-cert.sh fqdn <port>"
 exit
else 
  fqdn=$1
  port=443
fi
if [ "$#" -gt 1 ]; then
    port=$2
fi

echo "Testing cert on $fqdn port $port"

host $fqdn
	

echo | timeout 2 openssl s_client -showcerts -servername $fqdn  -connect $fqdn:$port 2>/dev/null | openssl x509 -inform pem -noout -text -dates | egrep -i "notafter"