fixing small bug

This commit is contained in:
brent s 2018-05-08 05:27:12 -04:00
parent 36c20eae91
commit 4f775159c8

View File

@ -196,6 +196,7 @@ class CertParse(object):
exts[keyname] = value_str exts[keyname] = value_str
# These are split FURTHER into dicts but require unique... massaging. # These are split FURTHER into dicts but require unique... massaging.
# authorityInfoAccess # authorityInfoAccess
if 'authorityInfoAccess' in exts.keys():
_tmp = copy.deepcopy(exts['authorityInfoAccess']) _tmp = copy.deepcopy(exts['authorityInfoAccess'])
exts['authorityInfoAccess'] = {} exts['authorityInfoAccess'] = {}
for i in _tmp: for i in _tmp:
@ -203,10 +204,12 @@ class CertParse(object):
y = [n.strip() for n in x[1].split(':', 1)] y = [n.strip() for n in x[1].split(':', 1)]
exts['authorityInfoAccess'][x[0]] = {y[0]: y[1]} exts['authorityInfoAccess'][x[0]] = {y[0]: y[1]}
# authorityKeyIdentifier # authorityKeyIdentifier
if 'authorityKeyIdentifier' in exts.keys():
_tmp = copy.deepcopy(exts['authorityKeyIdentifier']) _tmp = copy.deepcopy(exts['authorityKeyIdentifier'])
exts['authorityKeyIdentifier'] = {_tmp.split(':', 1)[0]: exts['authorityKeyIdentifier'] = {_tmp.split(':', 1)[0]:
_tmp.split(':', 1)[1]} _tmp.split(':', 1)[1]}
# basicConstraints # basicConstraints
if 'basicConstraints' in exts.keys():
_tmp = copy.deepcopy(exts['basicConstraints']) _tmp = copy.deepcopy(exts['basicConstraints'])
exts['basicConstraints'] = {} exts['basicConstraints'] = {}
for i in _tmp: for i in _tmp:
@ -219,6 +222,7 @@ class CertParse(object):
exts['basicConstraints'][x[0]] = True exts['basicConstraints'][x[0]] = True
# certificatePolicies # certificatePolicies
# What a mess. # What a mess.
if 'certificatePolicies' in exts.keys():
_tmp = copy.deepcopy(exts['certificatePolicies']) _tmp = copy.deepcopy(exts['certificatePolicies'])
exts['certificatePolicies'] = {} exts['certificatePolicies'] = {}
last_key = None last_key = None
@ -238,7 +242,8 @@ class CertParse(object):
last_key = l[0].strip() last_key = l[0].strip()
exts['certificatePolicies'][last_key] = {} exts['certificatePolicies'][last_key] = {}
# ct_precert_scts # ct_precert_scts
# another mess. # another mess. a much. much, bigger mess.
if 'ct_precert_scts' in exts.keys():
_tmp = copy.deepcopy(exts['ct_precert_scts']) _tmp = copy.deepcopy(exts['ct_precert_scts'])
exts['ct_precert_scts'] = {} exts['ct_precert_scts'] = {}
last_key = None last_key = None
@ -251,8 +256,8 @@ class CertParse(object):
# Is it a line continuation (of a hex value)? # Is it a line continuation (of a hex value)?
if ((re.search('^[0-9A-Z]{2}$', l[0])) and if ((re.search('^[0-9A-Z]{2}$', l[0])) and
(re.search('^[0-9A-Z:]*:?$', ':'.join(l)))): (re.search('^[0-9A-Z:]*:?$', ':'.join(l)))):
exts['ct_precert_scts'][last_key][cnt][last_sub_key] += \ exts['ct_precert_scts'][last_key][cnt]\
':'.join(l) [last_sub_key] += ':'.join(l)
continue continue
# It MAY be a key:value. # It MAY be a key:value.
if re.search('^\s+', l[1]) and ( if re.search('^\s+', l[1]) and (
@ -271,7 +276,8 @@ class CertParse(object):
val = None val = None
if last_sub_key == 'Signature': if last_sub_key == 'Signature':
val += ' ' val += ' '
exts['ct_precert_scts'][last_key][cnt][last_sub_key] = val exts['ct_precert_scts'][last_key][cnt]\
[last_sub_key] = val
else: else:
# Standalone key line # Standalone key line
last_key = l[0].strip() last_key = l[0].strip()
@ -282,8 +288,9 @@ class CertParse(object):
exts['ct_precert_scts'][last_key].append({}) exts['ct_precert_scts'][last_key].append({})
cnt += 1 cnt += 1
# some laaaast bit of cleanup... # some laaaast bit of cleanup...
if 'Signed Certificate Timestamp' in exts['ct_precert_scts'].keys(): if 'Signed Certificate Timestamp' in exts['ct_precert_scts']:
for i in exts['ct_precert_scts']['Signed Certificate Timestamp']: for i in exts['ct_precert_scts']\
['Signed Certificate Timestamp']:
if 'Signature' in i.keys(): if 'Signature' in i.keys():
d = i['Signature'].split() d = i['Signature'].split()
i['Signature'] = {d[0]: d[1]} i['Signature'] = {d[0]: d[1]}