Skip to content

Instantly share code, notes, and snippets.

@chrjoh
Created March 27, 2014 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chrjoh/9805762 to your computer and use it in GitHub Desktop.
Save chrjoh/9805762 to your computer and use it in GitHub Desktop.
loop over rows of hosts in a file and fetch the cerificate of each host and display the cerificate date's
#!/bin/sh
#
# usage: check_dates_all_hosts.sh hosts_file
# where hosts_:file is a file with one hostename per row
#
function get_cerificate {
REMHOST=$1
REMPORT=${2:-443}
echo |\
openssl s_client -connect ${REMHOST}:${REMPORT} 2>&1 |\
sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' |\
openssl x509 -noout -subject -dates
}
cat $1 | while read line
do
echo $line
get_cerificate $line
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment