SSL error 140770FC with requests behind company proxy

I can't use requests for https requests behind my company proxy. I'm not sure whether the problem is due to requests or my company proxy.

Example output:

```
>>> import requests
>>> requests.get("http://www.google.com")
<Response [200]>
>>> requests.get("https://www.google.com")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/edwardd/.local/lib/python2.7/site-packages/requests/api.py", line 55, in get
    return request('get', url, **kwargs)
  File "/home/edwardd/.local/lib/python2.7/site-packages/requests/api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/edwardd/.local/lib/python2.7/site-packages/requests/sessions.py", line 279, in request
    resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
  File "/home/edwardd/.local/lib/python2.7/site-packages/requests/sessions.py", line 374, in send
    r = adapter.send(request, **kwargs)
  File "/home/edwardd/.local/lib/python2.7/site-packages/requests/adapters.py", line 213, in send
    raise SSLError(e)
requests.exceptions.SSLError: [Errno 1] _ssl.c:504: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
```


This is a known issue. I'm surprised I can't find an already open issue in the tracker for it. We're waiting on one [pull request](https://github.com/shazow/urllib3/pull/139) in shazow/urllib3 and it will then be fixed.


This looks like #1182.

Quoting myself:

Does your proxy variable have a `https://` or `http://` scheme?
It should be `http://` if you want to connect by `http`, regardless if the the proxied connection itself is encrypted.


Yes, t-8ch, the proxy variable for https started with `https://`. Using `http://`, however, returns 501:

```
>>> requests.get("https://www.google.com")
<Response [501]>
```


@t-8ch this is probably just due to not sending 'CONNECT'


@eddie-dunn: To be clear, how are you passing the proxy information to Requests? Keyword argument or environment variable?


Environment variables. I have

```
edwardd@lnxedwardd> export | grep http
http_proxy=10.0.2.60:3128
https_proxy=10.0.2.60:3128
```

Don't think it makes a difference, though:

```
$ unset https_proxy
$ python
>>> import requests
>>> requests.get("https://www.google.com", proxies={"https": "10.0.2.60:3128"})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  <...>
requests.exceptions.SSLError: [Errno 1] _ssl.c:504: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
```


Excellent, that demonstrates the bug.

As @t-8ch and @sigmavirus24 pointed out, we currently cannot use HTTPS over proxies because we do not support the CONNECT verb. This is a known bug, and we're waiting on urllib3 before we can resolve it.


So... when is urllib3 due? And I guess the solution in the meantime is to not use requests and/or https?


Shazow is swamped so he won't be able to get to it for a while. The honest answer is that we don't know.

Unfortunately, as long as you're required to proxy out there's nothing we can do until that time. I'm sorry. =(


No need to apologize, I understand :) Is there an open issue/ticket somewhere referencing this problem so I can be notified when it does get solved? I have been thinking about using `requests` for applications here at work, but I'd like https with proxy to work first.


Keep an eye on shazow/urllib3#139.


Hello,

Looking at https://github.com/shazow/urllib3/pull/139, it seems it was closed. Do you know if the integration into requests is already in the work?

Thanks a lot!


It was already integrated. Requests 2.0.0 and upward contain the functionality.


Ok thanks for the precision. I still get the same error, but this is probably under different conditions.

Thanks again.