From 436afcc6ad338f0dae64846e750a6c129b40e30c Mon Sep 17 00:00:00 2001 From: Alexandre Dulaunoy Date: Mon, 17 Aug 2015 09:48:58 +0000 Subject: [PATCH] Better JSON output (subjects and certificate fp separated) --- bin/x509/ip-ssl-subject-api.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/x509/ip-ssl-subject-api.py b/bin/x509/ip-ssl-subject-api.py index a34f546..0ce0319 100644 --- a/bin/x509/ip-ssl-subject-api.py +++ b/bin/x509/ip-ssl-subject-api.py @@ -27,7 +27,7 @@ class SSLQueryHandler(tornado.web.RequestHandler): def get(self, input): try: #Redis structure Set of (FP) per IP - r = redis.StrictRedis(host='127.0.0.1', port=6381) + r = redis.StrictRedis(host='127.0.0.1', port=8323) except: print "Unable to connect to the Redis server" sys.exit(255) @@ -57,14 +57,17 @@ class SSLQueryHandler(tornado.web.RequestHandler): for ip in iplist: s = r.smembers(ip) if s: - out[str(ip)] = [] + out[str(ip)] = {} + out[str(ip)]['certificates'] = [] + out[str(ip)]['subjects'] = {} for fingerprint in s: subjects = r.smembers(fingerprint) + out[str(ip)]['certificates'].append(fingerprint) if subjects: + out[str(ip)]['subjects'][fingerprint] = {} + out[str(ip)]['subjects'][fingerprint]['values'] = [] for subject in subjects: - out[str(ip)].append(subject) - else: - out[str(ip)].append(fingerprint) + out[str(ip)]['subjects'][fingerprint]['values'].append(subject) if not self._finished: self.set_header('Content-Type', 'application/json')