Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a possible cause for [SSL: UNKNOWN_PROTOCOL] in Python Requests library?

The following example GET:

r = requests.get(url, auth=(self.key, ''), verify=False)

Fails with the following traceback:

File "/Library/Python/2.7/site-packages/requests/api.py", line 70, in get
return request('get', url, params=params, **kwargs)
File "/Library/Python/2.7/site-packages/requests/api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "/Library/Python/2.7/site-packages/requests/sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "/Library/Python/2.7/site-packages/requests/sessions.py", line 596, in send
r = adapter.send(request, **kwargs)

File "/Library/Python/2.7/site-packages/requests/adapters.py", line 497, in send
raise SSLError(e, request=request)

requests.exceptions.SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590)

Running python 2.7.12

I can confirm this IS NOT a duplicate of Python requests gives SSL unknown protocol

  • Question 32099208 is specific to a port issue on the requested URL
  • My target URL works as expected in clients other than Python Requests
    • https://api.bamboohr.com/api/gateway.php/test/v1/employees/directory
like image 401
Dan O'Boyle Avatar asked Oct 13 '16 18:10

Dan O'Boyle


People also ask

What causes SSL certificate errors Python?

What Causes an SSL Certificate_Verify_Failed Error? SSL certificate_verify_failed errors typically occur as a result of outdated Python default certificates or invalid root certificates. If you're a website owner and you're receiving this error, it could be because you're not using a valid SSL certificate.

What is SSL certificate Python requests?

Requests verifies SSL certificates for HTTPS requests, just like a web browser. SSL Certificates are small data files that digitally bind a cryptographic key to an organization's details. Often, a website with a SSL certificate is termed as secure website.


1 Answers

The solution to this problem turned out to be related to the requests library.

Adding the following to my python library resolved the issue:

pip install requests[security]

(Note this is not an ideal fix for TLS future security)

like image 97
Dan O'Boyle Avatar answered Nov 15 '22 09:11

Dan O'Boyle