'ValueError: check_hostname needs a SSL context with either CERT_OPTIONAL or CERT_REQUIRED

I am trying to connect to a ServiceNow server through proxy, but I am getting the error

File "/ps/python/lib/python3.6/site-packages/requests-2.20.0-py3.6.egg/requests/sessions.py", line 637, in send r = adapter.send(request, **kwargs) File "/ps/python/lib/python3.6/site-packages/requests-2.20.0-py3.6.egg/requests/adapters.py", line 449, in send timeout=timeout File "/ps/python/lib/python3.6/site-packages/urllib3/connectionpool.py", line 696, in urlopen self._prepare_proxy(conn) File "/ps/python/lib/python3.6/site-packages/urllib3/connectionpool.py", line 964, in _prepare_proxy conn.connect() File "/ps/python/lib/python3.6/site-packages/urllib3/connection.py", line 359, in connect conn = self._connect_tls_proxy(hostname, conn) File "//ps/python/lib/python3.6/site-packages/urllib3/connection.py", line 496, in _connect_tls_proxy ssl_context.check_hostname = True ValueError: check_hostname needs a SSL context with either CERT_OPTIONAL or CERT_REQUIRED

This is my code:

self.headers = '{'Content-Type': 'application/json', 'Accept': 'application/json', 'User-Agent': 'runscope/0.1'}'
request_obj = requests.Request("POST", "https://servicenow.com/api/now/table/u_kiss_fmo_request_interface_sc", data={some JSON data}, auth=self.auth_tuple, headers=self.headers, cookies=kwargs.get('cookies'))

Any ideas?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source