Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Unable to get the transport ssl context from the request. This prevents checking the Client provided certificate and matching up the provided CN against allowed users/server. #2306

Closed
2 tasks done
desean1625 opened this issue Apr 15, 2024 · 0 comments

Comments

@desean1625
Copy link

desean1625 commented Apr 15, 2024

Initial Checks

  • I confirm this was discussed, and the maintainers suggest I open an issue.
  • I'm aware that if I created this issue without a discussion, it may be closed without a response.

Discussion Link

https://github.com/encode/uvicorn/issues/745

Description

Many applications in finance/banking require two way certificate verification. Currently the way we have handled this is by proxying the request and extracting out the client information at nginx or traefik and stuffing it into the headers.

Example Code

From the request we cannot get the transport information and unable to getgetpeercert preventing application-level validation of client certificates.

A possible solution is to pass the transport in the request scope.
In the protocol h11_impl.py we could simply add

"transport":self.transport

after

Then at a route level or fastapi middleware we could pull the client certificates to check against an authorization service.

@app.get("/admin")
async def getAdminPage(request:Request):
  client_cert = request.scope['transport'].get_extra_info("ssl_object").getpeercert()
  #Verify user common name is an admin

Python, Uvicorn & OS Version

All

Important

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@encode encode locked and limited conversation to collaborators Apr 15, 2024
@Kludex Kludex converted this issue into discussion #2307 Apr 15, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant