Skip to content

Commit

Permalink
Fixes #286: Correct handling of ssl parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
3c7 committed Jun 12, 2018
1 parent e94f6f6 commit 05b78fc
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions analyzers/MISP/mispclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,18 @@ def __init__(self, url, key, ssl=True, name='Unnamed', proxies=None):
if isinstance(ssl, list):
if isinstance(ssl[idx], str) and os.path.isfile(ssl[idx]):
verify = ssl[idx]
elif isinstance(ssl[idx], str) and not os.path.isfile(ssl[idx]):
elif isinstance(ssl[idx], str) and not os.path.isfile(ssl[idx]) and ssl[idx] != "":
raise CertificateNotFoundError('Certificate not found under {}.'.format(ssl[idx]))
elif isinstance(ssl[idx], bool):
verify = ssl[idx]
else:
raise TypeError('SSL parameter is a not expected type: {}'.format(type(ssl[idx])))

# Do the same checks again, for the non-list type
elif isinstance(ssl, str) and os.path.isfile(ssl):
verify = ssl
elif isinstance(ssl, str) and not os.path.isfile(ssl):
elif isinstance(ssl, str) and not os.path.isfile(ssl) and ssl != "":
raise CertificateNotFoundError('Certificate not found under {}.'.format(ssl))
elif isinstance(ssl, bool):
verify = ssl
else:
raise TypeError('SSL parameter is a not expected type: {}'.format(type(ssl)))
self.misp_connections.append(pymisp.PyMISP(url=server,
key=key[idx],
ssl=verify,
Expand All @@ -67,7 +64,7 @@ def __init__(self, url, key, ssl=True, name='Unnamed', proxies=None):
verify = True
if isinstance(ssl, str) and os.path.isfile(ssl):
verify = ssl
elif isinstance(ssl, str)and not os.path.isfile(ssl):
elif isinstance(ssl, str) and not os.path.isfile(ssl) and ssl != "":
raise CertificateNotFoundError('Certificate not found under {}.'.format(ssl))
elif isinstance(ssl, bool):
verify = ssl
Expand Down

0 comments on commit 05b78fc

Please sign in to comment.