How do I extract the x509 commonName from a capture of the SSL handshake? I want all of the subject fields and all of the issuer fields from the signedCertificate(s). This works but only gets the last printableString from the signing authority.
I want the first certificate and all fields from the subject and issuer. I started using the GUI and looking at the bottom pane to get the names of everything and using tshark -G but no luck so far. I am using tshark -v 1.0.3, maybe there have been improvements in this area since this version? Any help is appreciated. Thanks. asked 23 Mar '12, 14:18 rafs showing 5 of 6 show 1 more comments |
3 Answers:
Ok, the aggregator field print option does the trick:
answered 20 Apr ‘12, 12:41 rafs |
You may have a problem, depending on the character encoding which was used for the various elements of the DN. From RFC 2459: The DirectoryString type is defined as a choice of PrintableString, TeletexString, BMPString, UTF8String, and UniversalString. The UTF8String encoding is the preferred encoding, and all certificates issued after December 31, 2003 MUST use the UTF8String encoding of DirectoryString (except as noted below). Until that date, conforming CAs MUST choose from the following options when creating a distinguished name, including their own:
answered 02 Apr ‘12, 15:19 inetdog Thanks, inetdog. I also found this document (http://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf) that apparently describes the character set encodings in way more detail than I can follow, but I think I got it. (20 Apr ‘12, 13:52) rafs |
I found what may be the best available solution for this problem.
In my opinion, the “-E quote=d|s|n” is implemented wrong. It should quote the individual fields, e.g. “Mountain View”,“Google Inc”,“mail.google.com”. The current 1.6.7 version has no way for you to distinguish the x509sat strings that have commas and single quotes in the field values, e.g. sometimes the field value could be something like “Google, Inc.”. Minor complaint aside, I say thank you to the developers that have contributed their time and talent to wireshark and tshark. This is a great tool. Thank you. answered 20 Apr ‘12, 12:23 rafs |
I discovered the "-V" option and I can work with this, but if there is a way to traverse this tree and selectively print the elements that would be even better.
tshark -r ssl.pcap -R ssl.handshake.certificate -V
I am just wondering if I need to write my own parser or will the tshark parser allow me to get the information I want all as tab delimited fields, one-line per handshake, using the -Tfields option.
The first one works but not the second:
$ tshark -r $PCAP -R "ssl.handshake.certificate" -Tfields -e x509sat.CountryName
JP
$ tshark -r $PCAP -R "ssl.handshake.certificate" -Tfields -e x509sat.CommonName
Does the certificate in question have a commonName? If not, presumably
-e x509sat.CommonName
won't work.yes, it has a id-at-commonName field