From 15183bf48f90bbb959e53ad21b8b0890bf982b22 Mon Sep 17 00:00:00 2001 From: Ted Xiao Date: Tue, 25 Feb 2020 10:32:28 +0800 Subject: [PATCH] fix AttributeError: 'module' object has no attribute '_create_unverified_context' --- splunklib/binding.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/splunklib/binding.py b/splunklib/binding.py index b0ed20e1b..0bca6e045 100644 --- a/splunklib/binding.py +++ b/splunklib/binding.py @@ -1368,7 +1368,11 @@ def connect(scheme, host, port): if cert_file is not None: kwargs['cert_file'] = cert_file if not verify: - kwargs['context'] = ssl._create_unverified_context() + try: + kwargs['context'] = ssl._create_unverified_context() + except AttributeError: + # Legacy Python that doesn't support verify PEP 476 + pass return six.moves.http_client.HTTPSConnection(host, port, **kwargs) raise ValueError("unsupported scheme: %s" % scheme)