From 05b78fcda967b09e0e225ba2b4f4822721daee3a Mon Sep 17 00:00:00 2001 From: Nils Kuhnert Date: Tue, 12 Jun 2018 08:50:10 +0200 Subject: [PATCH] Fixes #286: Correct handling of ssl parameter --- analyzers/MISP/mispclient.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/analyzers/MISP/mispclient.py b/analyzers/MISP/mispclient.py index ee8decd..6f2b488 100755 --- a/analyzers/MISP/mispclient.py +++ b/analyzers/MISP/mispclient.py @@ -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