Fixes #286: Correct handling of ssl parameter

This commit is contained in:
Nils Kuhnert 2018-06-12 08:50:10 +02:00
parent e94f6f698f
commit 05b78fcda9
No known key found for this signature in database
GPG Key ID: 3591DD5B3103ED50

View File

@ -44,21 +44,18 @@ class MISPClient:
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,
@ -67,7 +64,7 @@ class MISPClient:
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