mirror of
https://github.com/adulau/crl-monitor.git
synced 2024-11-24 11:07:14 +00:00
Importing ICSI results into Redis
This commit is contained in:
parent
c7a6d5dfd8
commit
d2a4c8c6f4
1 changed files with 15 additions and 3 deletions
|
@ -11,6 +11,8 @@
|
||||||
import dns.resolver
|
import dns.resolver
|
||||||
import argparse
|
import argparse
|
||||||
import fileinput
|
import fileinput
|
||||||
|
import shlex
|
||||||
|
import redis
|
||||||
|
|
||||||
suffix = '.notary.icsi.berkeley.edu'
|
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')
|
argParser.add_argument('-r', default='-', help='Read from a file, default is stdin')
|
||||||
args = argParser.parse_args()
|
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):
|
for l in fileinput.input(args.r):
|
||||||
fp = l.rstrip()
|
fp = l.rstrip().lower()
|
||||||
try:
|
try:
|
||||||
r = resolver.query(fp+suffix, 'TXT')[0]
|
r = resolver.query(fp+suffix, 'TXT')
|
||||||
except:
|
except:
|
||||||
print ("Non-existing certificate {}".format(fp))
|
print ("Non-existing certificate {}".format(fp))
|
||||||
continue
|
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]))
|
||||||
|
|
Loading…
Reference in a new issue