Skip to content

Instantly share code, notes, and snippets.

@gene1wood
Last active July 18, 2019 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gene1wood/6530100 to your computer and use it in GitHub Desktop.
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
#!/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
@gene1wood
Copy link
Author

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