Last active
February 10, 2016 11:47
-
-
Save binarytemple/1c96d62ea22d71d60c94 to your computer and use it in GitHub Desktop.
I'm sure it's been done before, but here's a script which dumps asn information from PEM encoded x509 certificate files
This file contains hidden or 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
| #!/usr/bin/awk -f | |
| # Takes a single argument, the path to a file containing PEM encoded certificate(s) | |
| BEGIN{count=0} | |
| /-----BEGIN CERTIFICATE-----/{ | |
| count++ | |
| items[count] = $0 | |
| } | |
| /-----END CERTIFICATE-----/{ | |
| items[count] = items[count] "\n" $0 | |
| } | |
| !/---/{ | |
| items[count] = items[count] "\n" $0 | |
| } | |
| END{ | |
| for (item in items) { | |
| sanitize="| tr -cd '[a-zA-Z0-9= -\(\):<>+\.\/\n]' |" | |
| cmd = "cat <<END " sanitize " openssl x509 -noout -text " | |
| cmd = cmd "\n" "END" | |
| system(cmd) | |
| } | |
| } |
Author
Author
tr works on OS-X irrespective of the position of the newline ('\n') in the list of allowed characters, on Linux it crashes unless it's the last character in the list.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
really wonder if this enough... this script is only for use with trusted input sources