-
-
Notifications
You must be signed in to change notification settings - Fork 743
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
Add client certificate to request scope #745
Comments
Copying context from our chat space... https://gitter.im/encode/community?at=5f2d60db79da21426f1d11a0 mdgilene:
tomchristie:
|
I have submitted a proposal to the ASGI spec django/asgiref#187 and will see if it gets any traction. If it does, then I will re-raise the issue here. |
I've created a pull request for an "ASGI TLS Extension" that would include this, as well as various other bits of TLS information. django/asgiref#192. Comments & feedback welcome on the pull request. |
Hey @jonfoster, I've just started implementing this in wagnerflo/uvicorn@de23ac8. For my personal use I just need Since I need this for testing and development only (in production I'll be running my applications behind a reverse proxy that'll send the client certificate as a header) I won't be putting any more work in. Also with my very, very limited experience working with the standard library
I appreciate the work you've put into this and would very much like to have this included in ASGI servers, but IMHO you're setting the bar to entry (work and amount of code/dependencies) to fully support the extension too high to get it adopted widely. Just my two cents. |
Hi @wagnerflo, I agree with you about the certificate form, I hadn't realised DER was easier. I can change that. The problem I have with tls_version/cipher is that I want the values to be well-specified, so it is interoperable. And not just specified as "go read the OpenSSL source code and figure out what it does". My experience with OpenSSL is that it's API is extremely poorly documented. I'm not aware of a document mapping the OpenSSL-defined cipher names to the standard names specified in the RFCs and/or the standard cipher numbers. A lot of open-source software does things the OpenSSL way just because they use OpenSSL and that's easiest for the implementer. But it's hard for someone using the API, or even for someone trying to implement the API using a different TLS library, because the API is effectively undocumented. I'd include Python's standard "ssl" module in that category. My background includes writing international standards, I want things to be properly specified & documented. So the API design I came up with puts the cost of understanding OpenSSL, and translating OpenSSL's non-standard cipher names etc into something standard, on the person using OpenSSL. An application using the API user has a well-documented API. Probably the best long-term solution would be to extend both the OpenSSL API and the Python SSL module, so they can provide the version and ciphersuite using the wire-protocol numbers. In the short term, perhaps I (or another volunteer) could write a library to do the conversions and publish it on PyPi, for use on existing versions of Python that don't have those APIs. Re the subject key, I agree it's not good but I struggled to find a better solution. I couldn't find any other specification for how to change a subject into a string. And I wanted a single string as that can be used directly as a "username". Perhaps I can specify a simpler encoding. Thanks for the feedback! |
I'm very much with you there. It's just a hurdle. Though just simply putting off implementing this part of your specification might be fine, IMHO. I can't think of any reason I'd need these protocol parameters in the web application proper.
There also seems to be a format specified in RFC2253. No idea if that'd be any easier to convert to from the
Yes. That's genuinely useful and basically what I'm also doing. Just that I'm only using the CN part... |
Checklist
Is your feature related to a problem? Please describe.
Currently there is no way to access the client certificate sent with a request from application without setting up some kind of proxy in front of the server that adds the information to the request headers.
Describe the solution you would like.
The client certificate information should be added to the request scope.
I have already tested a solution to this and would be ready to submit a PR for this feature. You can view the potential implementation here mdgilene@9407f0b
Describe alternatives you considered
Setup a proxy server in front of Uvicorn to add the required information to the request headers.
Additional context
This ability is available in server implementations in other languages. Why should the python world be different?
The text was updated successfully, but these errors were encountered: