Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python-requests 2.0.0 - [Errno 8] _ssl.c:504: EOF occurred in violation of protocol

I'm using Requests 2.0.0 and failed to complete https GET request using:

requests.get('https://backend.iddiction.com/rest/v1/s2s/confirm_install?apphandle=slotsjourneyofmagic&appsecret=5100d103e146e2c3f22af2c24ff4e2ec&mac=50:EA:D6:E7:9B:C2&idfa=134DA32A-A99F-4864-B69E-4A7A2EFC6C25')

I get this Error:

[Errno 8] _ssl.c:504: EOF occurred in violation of protocol.

I read a lot of content on the web and on this site but every where i read it says that those problems fixed in version 2.0.0.

Can anyone advice here?

like image 212
Alon Rolnik Avatar asked Oct 16 '13 09:10

Alon Rolnik


1 Answers

The server requires that you use SNI, which isn't normally available in Python 2.x.

If you open that URL in a browser and use Wireshark to trace out the TLS handshake, you can see that Chrome proposes the server name and that the remote server uses it to determine which certificate to use.

To make this work in Requests you can either use Python 3, which includes SNI support and which Requests will transparently make use of, or you can install the required dependencies for SNI in Python 2.x in Requests from this answer:

  • pyopenssl
  • ndg-httpsclient
  • pyasn1

Either of those solutions will make your code work correctly.

like image 183
Lukasa Avatar answered Oct 06 '22 19:10

Lukasa