-
-
Notifications
You must be signed in to change notification settings - Fork 811
Asgiref tls extension proposal #2586
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
Open
eirikhex
wants to merge
18
commits into
encode:master
Choose a base branch
from
eirikhex:asgiref-tls-extension-proposal
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
016c230
Implement asgiref tls extension
eirikhex b3f1f6f
Only add tls extension if connection is over tls
mdgilene 1944afc
Fix formatting issues
mdgilene fc065bf
Address linting issues and fix tests
mdgilene 090d1cd
Fix issues found by check script
adb8535
add generated TLS constants
jschlyter 4efb397
Add generate script and update generation to run formatting automatic…
626a256
Added DN escaping and use new generated cipher_suite lookup table
01215dd
Add test for escaping
ac16263
Run formatting on tests
4c851d6
fix incorrect dictionary access
b5c8690
Simplify and remove code
eirikhex 1dfa435
fix coverage
eirikhex 534e8d1
run linting
eirikhex 635f6ff
Move tlsInfo directly to the scope, drop the attribute
eirikhex 3186a0d
move TLSInfo to _types
eirikhex 1fc2beb
cosmetic change
eirikhex d376619
use unused_tcp_port in tests
eirikhex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,13 @@ def tls_certificate(tls_certificate_authority: trustme.CA) -> trustme.LeafCert: | |
) | ||
|
||
|
||
@pytest.fixture | ||
def tls_client_certificate(request, tls_certificate_authority: trustme.CA) -> trustme.LeafCert: | ||
return tls_certificate_authority.issue_cert( | ||
"[email protected]", common_name=getattr(request, "param", "uvicorn client") | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def tls_ca_certificate_pem_path(tls_certificate_authority: trustme.CA): | ||
with tls_certificate_authority.cert_pem.tempfile() as ca_cert_pem: | ||
|
@@ -107,6 +114,20 @@ def tls_ca_ssl_context(tls_certificate_authority: trustme.CA) -> ssl.SSLContext: | |
return ssl_ctx | ||
|
||
|
||
@pytest.fixture | ||
def tls_client_ssl_context( | ||
tls_certificate_authority: trustme.CA, tls_client_certificate: trustme.LeafCert | ||
) -> ssl.SSLContext: | ||
ssl_ctx = ssl.create_default_context(ssl.Purpose.SERVER_AUTH) | ||
tls_certificate_authority.configure_trust(ssl_ctx) | ||
|
||
# Load the client certificate chain into the SSL context | ||
with tls_client_certificate.private_key_and_cert_chain_pem.tempfile() as client_cert_pem: | ||
ssl_ctx.load_cert_chain(certfile=client_cert_pem) | ||
|
||
return ssl_ctx | ||
|
||
|
||
@pytest.fixture(scope="package") | ||
def reload_directory_structure(tmp_path_factory: pytest.TempPathFactory): | ||
""" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?