-
-
Save awsvpc/4b9306ee07424a9f591d139427e65830 to your computer and use it in GitHub Desktop.
Given a list of IP addresses (in file 'ips') find what the SSL CN (subject) is for each one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Given a list of IP addresses (in file 'ips') find what the SSL CN (subject) is for each one. | |
| echo -en "IP\tSSL CN\n" | |
| for i in `cat ips`; do | |
| echo -en "$i\t" | |
| out=`timeout 2 bash -c "openssl s_client -showcerts -connect $i:443 < /dev/null 2> /dev/null | openssl x509 -noout -subject 2> /dev/null | grep 'subject=' | sed -rn 's/.*CN=([^ /]+).*/\1/p'"` | |
| if [ $? -eq 124 ]; then | |
| echo "(timeout)" | |
| elif [ -z $out ]; then | |
| echo "(unknown)" | |
| else | |
| echo $out | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment