-
-
Save gene1wood/6530100 to your computer and use it in GitHub Desktop.
Tool to show cert, key or CSR information for a file or site
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/bash | |
if [ -e "$1" ]; then | |
if grep -- ' PRIVATE KEY-' "$1" >/dev/null; then | |
action=rsa | |
elif grep -- '-BEGIN CERTIFICATE REQUEST-' "$1" >/dev/null; then | |
action=req | |
elif grep -- '-BEGIN CERTIFICATE-' "$1" >/dev/null; then | |
action=x509 | |
else | |
action=unknown | |
fi | |
if [ "$action" = "unknown" ]; then | |
echo "Couldn't detect the file type of $1" | |
exit 1 | |
fi | |
echo -n | openssl $action -in "$1" -noout -text | |
else | |
echo -n | openssl s_client -connect $1:443 | openssl x509 -text | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See also https://github.com/mozilla-it/cert-tools/blob/master/ssl-inspect