Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-99813: Start usingSSL_sendfile
when available#99907
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
a018beb
72e7f5e
cf24d78
e9ef747
646d328
76353c7
14832de
6b41d31
8ac6ff9
5cf9483
fc8e82f
7fc9b50
1ba04ae
365e0c0
8fbc955
21ea0ca
17d9685
a92ae7e
4e8b6d8
379d242
7de3dcb
bbe21c0
7323ec0
2dc6947
6e902ad
e435b9a
ac1b2b2
7d11a59
99e89d3
dc626c8
291a5b7
3193ba4
d870f92
94e522e
25bde6f
9a6a120
eaa0b2c
05a0c6c
6b4eed6
31ed52d
5a22e6b
ada3f30
3350854
3339673
ee573ad
6795f62
6a35ac6
9dffdbd
19d5746
ef3744e
e64f329
028067a
6e099fa
f363ec3
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -4297,19 +4297,30 @@ def test_read_write_after_close_raises_valuerror(self): | ||
self.assertRaises(ValueError, s.write, b'hello') | ||
def test_sendfile(self): | ||
"""Try to send a file using kTLS if possible.""" | ||
TEST_DATA = b"x" * 512 | ||
with open(os_helper.TESTFN, 'wb') as f: | ||
f.write(TEST_DATA) | ||
self.addCleanup(os_helper.unlink, os_helper.TESTFN) | ||
client_context, server_context, hostname = testing_context() | ||
client_context.options |= getattr(ssl, 'OP_ENABLE_KTLS', 0) | ||
server = ThreadedEchoServer(context=server_context, chatty=False) | ||
# kTLS seems to work only with a connection created before | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Can you check whether it "seems" to work or not? (for a personal project I would accept this but I'm interested in knowing whether this is an issue with Python SSL or OpenSSL) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Okay, I'll post more details about this soon There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I can reproduce the same issue with C code using OpenSSL (without Python). Please check my findingshere. I mentioned a possible patch, let me know if we can apply it or there can be undesirable consequences. FYI, I added my reproducer to an existing OpenSSL issueopenssl/openssl#19676 (comment). | ||
# wrapping `sock` by the SSL context in contrast to calling | ||
# `sock.connect()` after the wrapping. | ||
with server, socket.create_connection((HOST, server.port)) as sock: | ||
with client_context.wrap_socket( | ||
sock, server_hostname=hostname | ||
) as ssock: | ||
if support.verbose: | ||
ktls_used = ssock._sslobj.uses_ktls_for_send() | ||
print( | ||
'kTLS is', | ||
'available' if ktls_used else 'unavailable', | ||
) | ||
illia-v marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
with open(os_helper.TESTFN, 'rb') as file: | ||
ssock.sendfile(file) | ||
self.assertEqual(ssock.recv(1024), TEST_DATA) | ||
def test_session(self): | ||
client_context, server_context, hostname = testing_context() | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
:mod:`ssl` now uses ``SSL_sendfile`` internally when it is possible (see | ||
:data:`~ssl.OP_ENABLE_KTLS`). The function sends a file more efficiently | ||
because it performs TLS encryption in the kernel to avoid additional context | ||
switches. Patch by Illia Volochii. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.