Last active
June 17, 2019 15:59
-
-
Save hatemzidi/a7468c8f1ae7c6773e93cf62dfe83d41 to your computer and use it in GitHub Desktop.
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
# https://unix.stackexchange.com/a/487546 | |
openssl s_client -showcerts -verify 5 -connect $HOST:$PORT < /dev/null | awk '/BEGIN/,/END/{ if(/BEGIN/){a++}; out="cert"a".crt"; print >out}' && for cert in *.crt; do newname=$(openssl x509 -noout -subject -in $cert | sed -n 's/^.*CN=\(.*\)$/\1/; s/[ ,.*]/_/g; s/__/_/g; s/^_//g;p').pem; mv $cert $newname; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment