SSLError: [Errno bad handshake] (-1, 'Unexpected EOF')

Hi, i have a service for send email through SMTP with [Mandrill](https://mandrillapp.com). 

``` python
# Service
from django.core.mail import EmailMessage
e = EmailMessage('test subject', 'test message', 'test@mail.com', ['me@me.com'])
e.send()
```

Throws this exception trace:

``` python
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/opt/apps/project/virtualenv/project/lib/python2.7/site-packages/django/core/mail/message.py", line 286, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/opt/apps/project/virtualenv/project/lib/python2.7/site-packages/djrill/mail/backends/djrill.py", line 68, in send_messages
    sent = self._send(message)
  File "/opt/apps/project/virtualenv/project/lib/python2.7/site-packages/djrill/mail/backends/djrill.py", line 107, in _send
    response = requests.post(api_url, data=json.dumps(api_params, cls=JSONDateUTCEncoder))
  File "/opt/apps/project/virtualenv/project/lib/python2.7/site-packages/requests/api.py", line 109, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/opt/apps/project/virtualenv/project/lib/python2.7/site-packages/requests/api.py", line 50, in request
    response = session.request(method=method, url=url, **kwargs)
  File "/opt/apps/project/virtualenv/project/lib/python2.7/site-packages/requests/sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "/opt/apps/project/virtualenv/project/lib/python2.7/site-packages/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/opt/apps/project/virtualenv/project/lib/python2.7/site-packages/requests/adapters.py", line 431, in send
    raise SSLError(e, request=request)
SSLError: [Errno bad handshake] (-1, 'Unexpected EOF')
```

Env: Red Hat 4.8.2-13, Python: 2.7.5
Libs:

```
Django==1.7.4
requests==2.7.0
djrill==1.3.0
pyOpenSSL==0.14
```

Any suggestions?

Going with [this](http://stackoverflow.com/questions/29504955/send-requests-to-twitter-with-requests-requests-exceptions-sslerror-errno) answer did not change anything.

Thanks in advance.


Unexpected EOF in this instance almost certainly means that there is a problem with your TLS handshake, and the server just tore the connection down rather than establish the TLS connection.

Firstly, you should install pyasn1 and ndg-httpsclient in addition to your current libraries: that will resolve your possible SNI issue. Then, if that didn't help, you should let me know what version of OpenSSL is installed in your system.


@Lukasa Already installed those libs, alike, running with --upgrade tells `Requirement already up-to-date`


@PabloLefort And your OpenSSL version, please?


@Lukasa OpenSSl version: `OpenSSL 1.0.1e-fips 11 Feb 2013`


Right, so there's no immediately obvious set of problems there. Are you familiar with Wireshark? If so, it'd be very convenient if you could grab a packet capture of the failing connection.


I'm not familiar but i will try to grab the packet and post the response.
Thanks.


@Lukasa So, after some investigation, installed `tcpdump` to see whats happening with the packets.
On my local env the connection was through `TLS`, but in the server first try to connect with `TLS` and fallback to `SSL`. This raise `EOF Exception`.
Going foward, there was some firewall closing every connection. I changed it and it works like a charm!

Thanks for all.


I would like to note, that problems may be relating on the proxy settings. Unset https_proxy and http_proxy.

Thanks! @VladislavMesh 🚀