Python 3.4 SSL error urlopen error EOF occurred in violation of protocol (_ssl.c:600)

31,716

Solution 1

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]>

Solution 2

One potential solution is described here

https://github.com/kennethreitz/requests/issues/3006#issuecomment-274058323

https://web.archive.org/web/20160705110216/https://github.com/kennethreitz/requests/issues/3006

Using python3 and installing the combo (pyopenssl ndg-httpsclient pyasn1 urllib3) did the trick.

pip install pyopenssl ndg-httpsclient pyasn1 urllib3
Share:
31,716
Lamp town guy
Author by

Lamp town guy

Updated on July 14, 2022

Comments

  • Lamp town guy
    Lamp town guy almost 2 years

    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

  • jcomeau_ictx
    jcomeau_ictx over 8 years
    doesn't work with openssl 1.0.0e-2ubuntu and python 3.2.2, site www.pca.org.