Skip to content

Commit 9747cfa

Browse files
author
Scott Odle
committed
don't check for ssl support if we're not verifying anyway
1 parent 84eeeed commit 9747cfa

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

splunklib/binding.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,17 +1343,14 @@ def connect(scheme, host, port):
13431343
if timeout is not None: kwargs['timeout'] = timeout
13441344
if scheme == "http":
13451345
return six.moves.http_client.HTTPConnection(host, port, **kwargs)
1346-
if scheme == "https" and verify:
1347-
if hasssl:
1348-
if key_file is not None: kwargs['key_file'] = key_file
1349-
if cert_file is not None: kwargs['cert_file'] = cert_file
1350-
1351-
# If running Python 2.7.9+, disable SSL certificate validation
1352-
if (sys.version_info >= (2,7,9) and key_file is None and cert_file is None) or not verify:
1353-
kwargs['context'] = ssl._create_unverified_context()
1354-
return six.moves.http_client.HTTPSConnection(host, port, **kwargs)
1355-
else:
1356-
raise ImportError('No SSL library found')
1346+
if scheme == "https":
1347+
if key_file is not None: kwargs['key_file'] = key_file
1348+
if cert_file is not None: kwargs['cert_file'] = cert_file
1349+
1350+
# If running Python 2.7.9+, disable SSL certificate validation
1351+
if (sys.version_info >= (2,7,9) and key_file is None and cert_file is None) or not verify or not hasssl:
1352+
kwargs['context'] = ssl._create_unverified_context()
1353+
return six.moves.http_client.HTTPSConnection(host, port, **kwargs)
13571354
raise ValueError("unsupported scheme: %s" % scheme)
13581355

13591356
def request(url, message, **kwargs):

0 commit comments

Comments
 (0)