简体   繁体   English

urllib3 on python 2.7 Google App Engine上的SNI错误

[英]urllib3 on python 2.7 SNI error on Google App Engine

I'm trying to download an HTTPS page from my site hosted on Google App Engine with SNI. 我正在尝试使用SNI从我在Google App Engine上托管的网站下载HTTPS页面。 No matter what library I use, I get the following error: 无论我使用什么库,我都会收到以下错误:

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

I've tried solving the error in many ways, including using the urllib3 openssl monkeypatch: 我尝试过多种方式解决错误,包括使用urllib3 openssl monkeypatch:

from urllib3.contrib import pyopenssl
pyopenssl.inject_into_urllib3

But I always get the same error mentioned above. 但我总是得到上面提到的同样的错误。

Any ideas? 有任何想法吗?

Unfortunately for urllib3, the Python standard library did not add SNI support until Python 3.2. 不幸的是,对于urllib3,Python标准库在Python 3.2之前没有添加SNI支持。 (See Issue #118 @ urllib3 ) (参见问题#118 @ urllib3

To use SNI in Python 2.7 with urllib3, you'll need to use the PyOpenSSL injection monkeypatch. 要在Python 2.7中使用urllib3中的SNI,您需要使用PyOpenSSL注入monkeypatch。 (See Issue #156 @ urllib3 ) (参见问题#156 @ urllib3

from urllib3.contrib import pyopenssl
pyopenssl.inject_into_urllib3()

Your question basically had the same code, except it was missing the parentheses call on the pyopenssl.inject_into_urllib3() call. 您的问题基本上具有相同的代码,除了它缺少对pyopenssl.inject_into_urllib3()调用的括号调用。 Fixing that should do the trick. 修复应该做的伎俩。

You'll also need to make sure to have the following dependencies available: 您还需要确保具有以下可用依赖项:

  • pyOpenSSL (tested with 0.13) pyOpenSSL(用0.13测试)
  • ndg-httpsclient (tested with 0.3.2) ndg-httpsclient(用0.3.2测试)
  • pyasn1 (tested with 0.1.6) pyasn1(用0.1.6测试)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM