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

Asgiref tls extension proposal #2586

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

eirikhex
Copy link

@eirikhex eirikhex commented Feb 21, 2025

Summary

Simplification of #1119 according to the discussion in django/asgiref#466
A proof of concept for a change in the asgi spec for the tls extension where
client_cert_name is removed because it's not the role of the ASGI web server to parse X.509 certificate. The content of the field is a part of the client_cert_chain, and should be extracted from there. (as shown in the test in this PR)
client_cert_error is removed as it was impossible to fill with any useful information.
tls_version and cipher_suite is filled with string returned by ssl.SSLSocket.version() and ssl.SSLSocket.cipher()

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

@eirikhex eirikhex force-pushed the asgiref-tls-extension-proposal branch 9 times, most recently from ece9cf9 to 78a2f6e Compare February 22, 2025 23:20
@@ -260,6 +260,7 @@ def __init__(
self.callback_notify = callback_notify
self.ssl_keyfile = ssl_keyfile
self.ssl_certfile = ssl_certfile
self.ssl_cert_pem: str | None = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you add this? Seems out of scope?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added in order to serve read and store the server cert pem one place. This need to be passed to the scope, and the file should not be read on every request.

should this be placed somewhere else?

Comment on lines 62 to 66
class TLSInfo(TypedDict, total=False):
server_cert: str | None
client_cert_chain: list[str]
tls_version: str | None
cipher_suite: str | None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to go in the _types module, and be added to the extensions key.

Copy link
Author

@eirikhex eirikhex Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit unsure about how that works. This is my attempt to fix it: 3186a0d

@Kludex Kludex added the waiting author Waiting for author's reply label Mar 9, 2025
@eirikhex eirikhex force-pushed the asgiref-tls-extension-proposal branch from 78a2f6e to db67d7a Compare March 11, 2025 20:28
@eirikhex eirikhex force-pushed the asgiref-tls-extension-proposal branch 2 times, most recently from 77edfda to 54fc797 Compare March 11, 2025 21:22
@eirikhex eirikhex force-pushed the asgiref-tls-extension-proposal branch from 54fc797 to a3bfb93 Compare March 11, 2025 22:02
@eirikhex eirikhex force-pushed the asgiref-tls-extension-proposal branch from a3bfb93 to 1fc2beb Compare March 11, 2025 22:30
@eirikhex eirikhex requested a review from Kludex March 11, 2025 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting author Waiting for author's reply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants