Skip to content

Instantly share code, notes, and snippets.

@dwdraju
Last active September 21, 2020 10:16
Show Gist options
  • Save dwdraju/bc7624503b851f7d0121eecad0a1ba19 to your computer and use it in GitHub Desktop.
Save dwdraju/bc7624503b851f7d0121eecad0a1ba19 to your computer and use it in GitHub Desktop.
Check ssl cert expiration and pem file
#!/bin/bash

if [ ! -z "$DEBUG" ]; then
  set -x
  DEBUG=
fi
DOMLIST="example.com"

for D in $DOMLIST
do
  if true | openssl s_client -connect $PREFIX${D}:443 2>/dev/null |   openssl x509 -noout -checkend 0; then  echo 'Certificate is not expired for '$PREFIX${D}' '; else   echo 'Certificate is expired for '$PREFIX${D}' ' > ssl_log.txt; fi
done

pem file check

echo | openssl s_client -showcerts -servername gnupg.org -connect gnupg.org:443 2>/dev/null | openssl x509 -inform pem -noout -text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment