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]))