Skip to content

Commit

Permalink
Add a couple fields to certificate in the JSON output
Browse files Browse the repository at this point in the history
  • Loading branch information
nabla-c0d3 committed Apr 16, 2017
1 parent 13a2ad8 commit 42d1361
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sslyze/cli/json_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from sslyze.cli import CompletedServerScan
from sslyze.cli import FailedServerScan
from sslyze.cli.output_generator import OutputGenerator
from sslyze.plugins.utils.certificate_utils import CertificateUtils
from sslyze.utils.python_compatibility import IS_PYTHON_2


Expand Down Expand Up @@ -75,7 +76,9 @@ def _object_to_json_dict(obj):
result = obj.name
elif isinstance(obj, cryptography.hazmat.backends.openssl.x509._Certificate):
# Properly serialize certificates; only return the PEM string
result = {'as_pem': obj.public_bytes(Encoding.PEM).decode('ascii')}
result = {'as_pem': obj.public_bytes(Encoding.PEM).decode('ascii'),
'hpkp_pin': CertificateUtils.get_hpkp_pin(obj),
'subject_name': CertificateUtils.get_printable_name(obj.subject)}
elif isinstance(obj, object):
result = {}
for key, value in obj.__dict__.items():
Expand Down

0 comments on commit 42d1361

Please sign in to comment.