Urllib3 on python 2.7 SNI Error in Google App Engine

I am trying to download an HTTPS page from my site hosted on Google App Engine using SNI. No matter which library I use, I get the following error:

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

I tried to solve this error in various ways, including using urllib3 openssl monkeypatch:

 from urllib3.contrib import pyopenssl pyopenssl.inject_into_urllib3 

But I always get the same error that was mentioned above.

Any ideas?

+5
python google-app-engine sni urllib3
Oct 20 '13 at 12:16
source share
1 answer

Unfortunately, for urllib3, the Python standard library did not add SNI support until Python 3.2. (See Issue No. 118 @ urllib3 )

To use SNI in Python 2.7 with urllib3, you will need to use PyOpenSSL injection monkeypatch. (See Issue No. 156 @ urllib3 )

 from urllib3.contrib import pyopenssl pyopenssl.inject_into_urllib3() 

Basically your question had the same code, except there was no call to parentheses in the call to pyopenssl.inject_into_urllib3() . A fix that should do the trick.

You also need to make sure that the following dependencies are available:

  • pyOpenSSL (checked from 0.13)
  • ndg-httpsclient (checked since 0.3.2)
  • pyasn1 (verified from 0.1.6)
+9
Oct 20 '13 at 12:34 on
source share



All Articles