Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an Extra for Better SSL Support #1995

Closed
dstufft opened this issue Apr 6, 2014 · 11 comments · Fixed by #2195
Closed

Create an Extra for Better SSL Support #1995

dstufft opened this issue Apr 6, 2014 · 11 comments · Fixed by #2195

Comments

@dstufft
Copy link
Contributor

dstufft commented Apr 6, 2014

So right now the SSL connections when you use pyOpenSSL, ndg-httspclient, and pyasn1 are more secure than if you just use the stdlib options. However it's hard to actually remember those three things. It would be cool if requests would add an extra to it's setup.py so that people can install requests with betterssl, something like:

setup(
    extras_require={
        "betterssl": ["pyOpenSSL", "ndg-httpsclient", "pyasn1"],
    },
)

Would make it so people can install requests like pip install requests[betterssl] and get all of those dependencies without having to manually track those down. It also means people could depend on requests[betterssl] instead of just requests in their own setup.py's.

Extra name can of course be bikeshed here :)

@dstufft
Copy link
Contributor Author

dstufft commented Apr 6, 2014

Also by default requests can't connect to some sites on OSX because of ancient OpenSSL. Using the above 3 packages makes it possible.

Python 2.7.5 (default, Sep 12 2013, 21:33:34)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> requests.get("https://www.howsmyssl.com/a/check")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/hynek/.virtualenvs/1bd80d533b702044/lib/python2.7/site-packages/requests/api.py", line 55, in get
    return request('get', url, **kwargs)
  File "/Users/hynek/.virtualenvs/1bd80d533b702044/lib/python2.7/site-packages/requests/api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Users/hynek/.virtualenvs/1bd80d533b702044/lib/python2.7/site-packages/requests/sessions.py", line 383, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/hynek/.virtualenvs/1bd80d533b702044/lib/python2.7/site-packages/requests/sessions.py", line 486, in send
    r = adapter.send(request, **kwargs)
  File "/Users/hynek/.virtualenvs/1bd80d533b702044/lib/python2.7/site-packages/requests/adapters.py", line 385, in send
    raise SSLError(e)
requests.exceptions.SSLError: [Errno 1] _ssl.c:504: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version

@sigmavirus24
Copy link
Contributor

I like this idea.

@alex
Copy link
Member

alex commented Apr 7, 2014

👍 from me as well.

@Lukasa
Copy link
Member

Lukasa commented Apr 7, 2014

I'm happy to do this as well. @kennethreitz, do you want to do this?

Would be nice if we could have a bit of the docs that talks about building the most secure possible form of requests, including stuff like installing OpenSSL from Homebrew and then building against that.

@t-8ch
Copy link
Contributor

t-8ch commented Apr 26, 2014

+1
This would be much better to document.
I would give it a neutral name a la PyOpenSSL as the other codepath isn't magic fairy dust and may exhibit other bugs.

@sigmavirus24
Copy link
Contributor

@dstufft can we do something like requests[+PyOpenSSL] or requests[+betterssl]? By which I mean: is the + allowed by distutils/setuptools?

@dstufft
Copy link
Contributor Author

dstufft commented Apr 26, 2014

Pretty sure it is not.

@alex
Copy link
Member

alex commented Apr 26, 2014

No, a + won't parse correctly on the pip install side.

On Sat, Apr 26, 2014 at 2:16 PM, Ian Cordasco notifications@git.luolix.topwrote:

@dstufft https://github.com/dstufft can we do something like
requests[+PyOpenSSL] or requests[+betterssl]? By which I mean: is the +allowed by distutils/setuptools?


Reply to this email directly or view it on GitHubhttps://github.com/kennethreitz/requests/issues/1995#issuecomment-41481134
.

"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
GPG Key fingerprint: 125F 5C67 DFE9 4084

@sigmavirus24
Copy link
Contributor

@kennethreitz any update on this?

@kennethreitz
Copy link
Contributor

I absolutely want to do this.

@sigmavirus24 sigmavirus24 self-assigned this Aug 29, 2014
bcb referenced this issue in explodinglabs/jsonrpcclient Sep 22, 2016
Python versions prior to 2.7.9 should install with pip install
'jsonrpcclient[requests_security]'. See requests issue
https://github.com/kennethreitz/requests/issues/1995 resolved in PR
https://github.com/kennethreitz/requests/pull/2195

Closes #31
This was referenced Jan 28, 2017
@SmartGeometry
Copy link

I found pyOpenSSL would cause memory problem, I use requests.get to request https://www.baidu.com for 10000times and memory growed!
ab983cf0-d52a-4347-8a5a-16912420c355

@psf psf locked as resolved and limited conversation to collaborators Oct 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants