Last active
May 1, 2016 16:43
-
-
Save likema/5a2651ed6acc324095ea9d9696a7f27b to your computer and use it in GitHub Desktop.
Show SSL certificate (from file or tcp) , certificate request and private key.
This file contains 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/sh | |
if [ $# -lt 1 ]; then | |
echo "$0 <host:port|SSL certificate|SSL certificate request|private key>" >&2 | |
exit 1 | |
fi | |
src=$1 | |
if [ -f $1 ]; then | |
grep -q -- '-BEGIN CERTIFICATE-' $src && openssl x509 -in $src -text -noout | |
grep -q -- '-BEGIN RSA PRIVATE KEY-' $src && openssl rsa -in $src -text -noout | |
grep -q -- '-BEGIN CERTIFICATE REQUEST-' $src && openssl req -in $src -text -noout | |
else | |
echo $src | grep -q ':' || src=$src:443 | |
openssl s_client -connect $src | sed -n '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' $stdout | openssl x509 -text -noout | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment