Last active
April 13, 2022 21:06
-
-
Save ThinGuy/9441ef5a4b0b131fc004ae838f9ed1ae to your computer and use it in GitHub Desktop.
Print all Subject Alternate Name (SAN) entries in a X509 cert (both hostname and IP addresses)
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
openssl x509 -in ${CERT} -noout -text|grep -oP '(?<=DNS:|IP Address:)[^,]+'|sort -uV | |
# Or as a function | |
show-cert-sans() { | |
[[ -z ${1} || ${1} =~ ^- ]] && { printf "Usage: ${FUNCNAME} </path/to/ssl/cert>\n";return 2; } || true | |
[[ -e ${1} ]] || { printf "Can't find SSL Certificate ${1}\n";return 1; } | |
openssl x509 -in ${1} -noout -text|grep -oP '(?<=DNS:|IP Address:)[^,]+'|sort -uV | |
} |
Author
ThinGuy
commented
Jan 20, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment