requests.exceptions.SSLError: EOF occurred in violation of protocol (_ssl.c:600)

```
r = requests.get('https://www.digitist.com', verify=False)
```

```
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/api.py", line 69, in get
    return request('get', url, params=params, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/api.py", line 50, in request
    response = session.request(method=method, url=url, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/adapters.py", line 431, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: EOF occurred in violation of protocol (_ssl.c:600)
```

I am using Python 3.4 on OSX Yosemite


Python 3.4, OS X Yosemite, Requests 2.7.0: I cannot reproduce this bug. =) Can you consistently hit it? What requests version are you using?


Also, what version of openssl and do you have `pyOpenSSL` installed?


requests 2.7.0
OpenSSL 1.0.2 22 Jan 2015
I did not have pyOpenSSL installed.

I installed the latest version of  pyOpenSSL 0.15.1  and ran the same request again.
Still the same result.


Are you behind a proxy?


No, I am not behind a proxy.


I consistently get this problem. By now, I have tried with 3 different networks. 

As soon as you are sure that this problem is not relative to requests, we can drop this :) because I only have this problem on my dev machine. Our production environment is Ubuntu and the request to the same url works fine there.

But until then, I am more than happy to give all the information you need for debugging.


The OpenSSL version number you gave us: how did you obtain it?


I typed in "openssl version" in the terminal:

```
Kristjans-MBP:leech kristjan$ openssl version
OpenSSL 1.0.2 22 Jan 2015
```

And for the one in Python:

```
>>> import OpenSSL
>>> OpenSSL.__version__
'0.15.1'
```


Sorry, can you do

``` python
import ssl
print ssl.OPENSSL_VERSION
```


```
>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 0.9.8zd 8 Jan 2015'
```


Awesome, so you're using a very old OpenSSL version. How did you install Python 3?


I used Mac OS X 64-bit/32-bit installer from here https://www.python.org/downloads/release/python-340/


Weird, I thought that bundled a newer OpenSSL. I recommend installing it using [Homebrew](http://brew.sh/), which will link against a newer OpenSSL.


What about macports? I use this as my package manager.

On 18:54, Fri, May 29, 2015 Cory Benfield notifications@github.com wrote:

> Weird, I thought that bundled a newer OpenSSL. I recommend installing it
> using Homebrew http://brew.sh/, which will link against a newer OpenSSL.
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/kennethreitz/requests/issues/2616#issuecomment-106855278
> .


I don't know about macports: you'll want to check with them whether they compile against the system OpenSSL or against one they provide.


If somebody still encounters this issue on their OS X stack I'll strongly recommend reinstalling Python 3 from https://www.python.org/downloads/  rather than homebrew - I've faced exactly the same thing and this was a proper solution for me :smile: 


@mieciu thanks for the input. That said, my recommendation is to use homebrew. :wink: 


EOF occurred in violation of protocol (_ssl.c:590) i am getting this error. 
do this
import requests
sess = requests.Session()
adapter = requests.adapters.HTTPAdapter(max_retries = 1000)
sess.mount('http://', adapter)

and do sess.post() but still got the same error. could you guys help me it that???


@biplab-dholey This error can occur for a number of reasons. The retries count is unrelated. This error results from your TLS configuration, and without more information it's very difficult for us to help.


I hit this error and I finally find I was accessing a none HTTPS service with a HTTPS protocol.

`SSLEOFError` occurred when getting `www.google.com` using proxies.
```python3
default_socket = socket.socket
socks.set_default_proxy(socks.SOCKS5, SOCKS5_PROXY_HOST, SOCKS5_PROXY_PORT)
socket.socket = socks.socksocket
import requests
html_source = requests.get(url, headers={"User-Agent": "Mozilla/5.001 (windows; U; NT4.0; en-US; rv:1.0) Gecko/25250101"}).text
```
```
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 560, in urlopen
    body=body, headers=headers)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 346, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 787, in _validate_conn
    conn.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 252, in connect
    ssl_version=resolved_ssl_version)
  File "/usr/lib/python3/dist-packages/urllib3/util/ssl_.py", line 305, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/lib/python3.5/ssl.py", line 377, in wrap_socket
    _context=self)
  File "/usr/lib/python3.5/ssl.py", line 752, in __init__
    self.do_handshake()
  File "/usr/lib/python3.5/ssl.py", line 988, in do_handshake
    self._sslobj.do_handshake()
  File "/usr/lib/python3.5/ssl.py", line 633, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:645)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 376, in send
    timeout=timeout
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 589, in urlopen
    raise SSLError(e)
requests.packages.urllib3.exceptions.SSLError: EOF occurred in violation of protocol (_ssl.c:645)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "request.py", line 19, in <module>
    html_source = requests.get(url, headers={"User-Agent": "Mozilla/5.001 (windows; U; NT4.0; en-US; rv:1.0) Gecko/25250101"}).text
  File "/usr/lib/python3/dist-packages/requests/api.py", line 67, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 53, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 447, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: EOF occurred in violation of protocol (_ssl.c:645)
```
the environment of my computer
```
Ubuntu 16.04
python3.5.2
>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 1.0.2g  1 Mar 2016'
>>> import requests
>>> requests.__version__
'2.9.1'
```

BUT, this code works well when getting `https://www.facebook.com/`