From d2a4c8c6f421713dc24568fcba3e0444740140ba Mon Sep 17 00:00:00 2001 From: Alexandre Dulaunoy Date: Fri, 2 Oct 2015 19:57:55 +0000 Subject: [PATCH] Importing ICSI results into Redis --- bin/x509/icsi.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/bin/x509/icsi.py b/bin/x509/icsi.py index 9b0b3c6..a9b0ec5 100644 --- a/bin/x509/icsi.py +++ b/bin/x509/icsi.py @@ -11,6 +11,8 @@ import dns.resolver import argparse import fileinput +import shlex +import redis suffix = '.notary.icsi.berkeley.edu' @@ -21,11 +23,21 @@ argParser = argparse.ArgumentParser(description='Lookup a series of certificate argParser.add_argument('-r', default='-', help='Read from a file, default is stdin') args = argParser.parse_args() +icsi_keys = ['version','first_seen','last_seen', 'times_seen', 'validated'] + +rstore = redis.StrictRedis(host='localhost', port=6380, db=5) + for l in fileinput.input(args.r): - fp = l.rstrip() + fp = l.rstrip().lower() try: - r = resolver.query(fp+suffix, 'TXT')[0] + r = resolver.query(fp+suffix, 'TXT') except: print ("Non-existing certificate {}".format(fp)) continue - print ("{},{}".format(fp,r)) + for rdata in r: + txt = rdata.strings[0] + rd = {} + rd = dict(token.split('=') for token in shlex.split(txt)) + rstore.hmset(fp, rd) + print (rd) + #print ("{},{}".format(fp,r[0]))