-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Switch to use SSLContext #1140
Comments
@berkerpeksag wanna want to do it? :) |
Will do, but I'm busy with job interviews these days so it can take a while :) |
Here's a diff that begins this work for anyone who wants to get started on this:
The We can also probably do this somewhere else, maybe in |
SSLContext is available to python 2.7: https://docs.python.org/2/library/ssl.html?highlight=sslcontext#ssl.SSLContext |
To share some experience from gevent, where this has been somewhat painful: SSLContext is available in Python 2.7.9 and above, or where backported by vendors (RedHat has backported as far back as 2.7.5). But it's not generally available in Python 2.7 as such. The generic version of 'pypy' that you get on Travis for example is pypy-2.5 which implements Python 2.7.8 and doesn't have it. gevent (still) has users that are on 2.7.9+, <=2.7.8, and using vendor backports. The bad thing about this is that it can lead to the python process actually crashing if you mix and match things in the wrong way. |
I'm using gunicorn (with Flask) for a smaller application and need to add client verification for just few URLs (not the whole application) while having a different client certificate for each client. Apart from the fact, that gunicorn only seems to support @tilgovi , @benoitc would you have any idea how to use SSLContext in a way to allow the client verification only for certain URL routes and having more client certificates (each client its own)? |
I don't know that Gunicorn could provide route-specific authentication, though I may not have a good picture of how SSL client authentication works (now, or in the future with SSLContext). I expect the authentication would be on the SSL handshake, before any HTTP protocol request is read. However, that does not mean your application needs to authorize access to routes without regard to the details of the authenticated client. Gunicorn would have to expose the peer certificate, following something like shown here: https://www.ajg.id.au/2018/01/01/mutual-tls-with-python-flask-and-werkzeug/ |
Thank you, I'll take a look at it. If it won't work for my case, I might in the end change my mind and lean towards an application layer authentication providing a one-way verification (the server got verified by the client) was successful and there is an encrypted channel to communicate through. |
In the end I rather solved authentication in the application layer to ease maintenance. There is one more thing I couldn't figure out with gunicorn. Is there a way how to exchange certificates (e.g. those passed to gunicorn through Use case is simple - using short-term certificates (e.g. Let's Encrypt) while maintaining "higher availability". |
An alternative solution for this could be instead of adding way too many ssl options and take the risk of changes in the python libraries, offer a server hook for the user to provide an SSL context. |
@benoitc, @berkerpeksag I can work with this issue if you don't mind? |
Another use case for this (which we need at $work): gunicorn doesn't allow disabling of TLS session renegotiation, a potential DoS vector. With access to the SSLContext, one could disable renegotiation and avoid this vuln. |
We need to use SSLContext in Python 3 (and perhaps 2.7.9+ too) to make Gunicorn users like easier. The old API is buggy and causes weird edge case bugs like reported in #1135.
The text was updated successfully, but these errors were encountered: