drwetter / testssl.sh

Testing TLS/SSL encryption anywhere on any port
https://testssl.sh
GNU General Public License v2.0
7.94k stars 1.02k forks source link

JSON output for multiple certificates: consider always numbering and/or additional JSON object #1084

Open happyc0ding opened 6 years ago

happyc0ding commented 6 years ago

Parsing the output of testssl is still a bit of a hazzle. Especially when reading the certificate data (both JSON and pretty JSON), the id "cert" is duplicated. The host "google.com" is a good example to reproduce this behaviour.

"severity"     : "INFO",
"finding"      : "-----BEGIN CERTIFICATE----- MIIISjCCBzKgAwIBAgIIWfk+L

...

"severity"     : "INFO",
"finding"      : "-----BEGIN CERTIFICATE----- MIIHjzCCBnegAwIBAgIIU9Ov

The other ids are labeled with sth. like "cert_fingerprintSHA256 <cert #1>". This is another issue, since the output of testssl changes: If there is only 1 certificate available, the "<cert #1>" part is missing. If parsing the output, I first have to check if sth. like "cert_fingerprintSHA256" is present and if not I have to check for "cert_fingerprintSHA256 <cert #1>". Maybe it is better to always keep the number in there, even if only 1 certificate is available? Or even better: Create a separate list for certificates instead of a flat structure with numbered "ids"?

I tested with the current testssl version ("09182cb 2018-07-05 09:54:58") on Linux.

drwetter commented 6 years ago

Thank you, understood .

1) the cert# in case of >1 certificates : that was just omitted which seems s bug.

2) the other point is a design decision I need to think about.

: If there is only 1 certificate available, the "<cert #1>" part is missing. If parsing the output, I first have to check if sth. like "cert_fingerprintSHA256" is present and if not I have to check for "cert_fingerprintSHA256 <cert #1>".

That should be just matches patterns? The logic I would apply is the number of different host certificates supplied (this is missing btw. in JSON). Then one could go from there. I understand though that this might be not straightforward.

Or even better: Create a separate list for certificates instead of a flat structure with numbered "ids"?

You mean in pretty JSON a separate object for each certificate?

happyc0ding commented 6 years ago

You mean in pretty JSON a separate object for each certificate?

Exactly.

drwetter commented 6 years ago

See above commit log for the first issue.

happyc0ding commented 6 years ago

Looks good, thanks!

drwetter commented 6 years ago

for 2) I am not sure whether I'll include it into this or the next release