Python 3.4 SSL error urlopen error EOF发生违反协议(_ssl.c:600) [英] Python 3.4 SSL error urlopen error EOF occurred in violation of protocol (_ssl.c:600)
问题描述
我使用 Arch Linux、python 3.4、openSSL 1.0.2d.当我向 https://www.supercash.cz/ 提出请求时,我收到此错误.无论我使用请求还是在 urllib 中构建,总是会出现相同的错误.此网站的 SSL 证书在 Chrome 浏览器中接缝正常.
文件/usr/lib64/python3.4/urllib/request.py",第463行,打开response = self._open(req, data)文件/usr/lib64/python3.4/urllib/request.py",第 481 行,在 _open'_open',请求)_call_chain 中的文件/usr/lib64/python3.4/urllib/request.py",第 441 行结果 = func(*args)https_open 中的文件/usr/lib64/python3.4/urllib/request.py",第 1225 行上下文=self._context,check_hostname=self._check_hostname)文件/usr/lib64/python3.4/urllib/request.py",第 1184 行,在 do_open引发 URLError(err)urllib.error.URLError: <urlopen error EOF发生违反协议(_ssl.c:600)>
我试过了,但它只适用于 python2.7错误 - urlopen 错误 [Errno8] _ssl.c:504: EOF 发生违反协议,需要帮助
这是 ssl 测试的结果 https://www.ssllabs.com/ssltest/analyze.html?d=supercash.cz
这和这个错误一样:Python 请求请求.exceptions.SSLError: [Errno 8] _ssl.c:504: EOF 发生违反协议
您必须使用此处所述的自定义 HTTPAdapter
:https://stackoverflow.com/a/14146031/407580
I use Arch Linux, python 3.4, openSSL 1.0.2d. When I make request to https://www.supercash.cz/ I get this error. It doesn't matter if I use requests or build in urllib there is always the same error. SSL certificate for this site seams to be OK in Chrome browser.
File "/usr/lib64/python3.4/urllib/request.py", line 463, in open
response = self._open(req, data)
File "/usr/lib64/python3.4/urllib/request.py", line 481, in _open
'_open', req)
File "/usr/lib64/python3.4/urllib/request.py", line 441, in _call_chain
result = func(*args)
File "/usr/lib64/python3.4/urllib/request.py", line 1225, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/usr/lib64/python3.4/urllib/request.py", line 1184, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error EOF occurred in violation of protocol (_ssl.c:600)>
I tried this but it only works in python2.7 Error - urlopen error [Errno 8] _ssl.c:504: EOF occurred in violation of protocol , help needed
This is result of ssl test https://www.ssllabs.com/ssltest/analyze.html?d=supercash.cz
This is the same error as this one: Python Requests requests.exceptions.SSLError: [Errno 8] _ssl.c:504: EOF occurred in violation of protocol
You'll have to use custom HTTPAdapter
as stated here: https://stackoverflow.com/a/14146031/407580
>>> import requests
>>> from requests.adapters import HTTPAdapter
>>> from requests.packages.urllib3.poolmanager import PoolManager
>>> import ssl
>>>
>>> class MyAdapter(HTTPAdapter):
... def init_poolmanager(self, connections, maxsize, block=False):
... self.poolmanager = PoolManager(num_pools=connections,
... maxsize=maxsize,
... block=block,
... ssl_version=ssl.PROTOCOL_TLSv1)
...
>>> s = requests.Session()
>>> s.mount('https://', MyAdapter())
>>> s.get('https://www.supercash.cz')
<Response [200]>
这篇关于Python 3.4 SSL error urlopen error EOF发生违反协议(_ssl.c:600)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!