checksslvalidity / checksslvalidity /
b53583b 7 years ago
1 contributor
26 lines | 0.579kb
#!/bin/bash
DOMAIN=$1

function usage() {
  echo "Usage: $(basename $0) DOMAIN.TLD [port]"
  echo ""
  echo " - DOMAIN.TLD : The tool will be connecting to this domain"
  echo "Optional:"
  echo " - port : If not set 443 will be used"
}

if [ "" == "$DOMAIN" ]
then
	usage
  exit 1
fi

PORT=$2
if [ "" == "$PORT" ]
then
  PORT=443
fi
echo Testing $DOMAIN:$PORT

/bin/echo | /usr/bin/openssl s_client -showcerts -servername $DOMAIN -connect $DOMAIN:$PORT 2>/dev/null | /usr/bin/openssl x509 -inform pem -noout -text| grep -e "DNS:" -e "Issuer:" -e "Not Before:" -e "Not After :"