Get list of subject alternative names of a domain
lssan () {
[[ $# -ne 1 ]] && echo 'Usage: lssan <DOMAIN>' || {
openssl s_client -connect $1:443 -servername $1 </dev/null 2>/dev/null | \
openssl x509 -text -noout | grep 'X509v3 Subject Alternative Name' -A 1 | \
tail -1 | tr ',' '\n' | awk -F: '{print $2}'
}
}
Mac only:
List, trust, distrust certs. You can also use the Keychain Access.app.
ls-cert () {
sudo security dump-keychain /Library/Keychains/System.keychain | \
grep 'class: 0x80001000' -A 10 | grep labl | \
awk '{e=substr($0, 19);print substr(e, 0, length(e)-1)}'
}
trust-cert () {
[[ $# -ne 1 ]] && echo 'Usage: trust-cert <CERT-FILE>' || {
sudo security add-trusted-cert -d -r trustRoot -k \
/Library/Keychains/System.keychain $1
}
}
distrust-cert () {
[[ $# -ne 1 ]] && echo 'Usage: distrust-cert <NAME>' || {
for hash in $(sudo security find-certificate -c "$1" -a -Z |
grep '^SHA-1 hash' | awk '{print $3}' | sort | uniq); do
sudo security delete-certificate -Z "$hash";
done
}
}