Created
October 13, 2018 07:57
-
-
Save brimston3/c45a42a07f49f92ceaf94126af0e67fb to your computer and use it in GitHub Desktop.
Inline expand x509 certificates using awk to buffer and openssl to parse.
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
# openssl s_client -connect google.com:443 -showcerts </dev/null | awk -f expand_certs_inline.awk | |
#or pack it all into one line, see if I care. | |
BEGIN{ | |
e=""; | |
flag=0; | |
ssl_proc_cmd="openssl x509 -noout -text"; | |
} | |
/-----BEGIN CERTIFICATE/{ | |
e=$0 "\n"; | |
l=NR; | |
flag=1; | |
next; | |
} | |
!flag{print} | |
/END CERTIFICATE-----/{ | |
e=e $0 "\n"; | |
print "### Cert at " l; | |
print e|ssl_proc_cmd; | |
close(ssl_proc_cmd); | |
e=""; | |
flag=0; | |
} | |
flag{ | |
e=e $0 "\n"; | |
} | |
END{ | |
if (flag) { | |
print "Unterminated certificate starting at" l; | |
print e; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment