mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-43577: Fix deadlock with SSLContext._msg_callback and sni_callback (GH-24957)
OpenSSL copies the internal message callback from SSL_CTX->msg_callback to SSL->msg_callback. SSL_set_SSL_CTX() does not update SSL->msg_callback to use the callback value of the new context. PySSL_set_context() now resets the callback and _PySSL_msg_callback() resets thread state in error path. Signed-off-by: Christian Heimes <christian@python.org>
This commit is contained in:
parent
20a5b7e986
commit
77cde5042a
4 changed files with 29 additions and 0 deletions
|
@ -4764,6 +4764,28 @@ class TestSSLDebug(unittest.TestCase):
|
|||
msg
|
||||
)
|
||||
|
||||
def test_msg_callback_deadlock_bpo43577(self):
|
||||
client_context, server_context, hostname = testing_context()
|
||||
server_context2 = testing_context()[1]
|
||||
|
||||
def msg_cb(conn, direction, version, content_type, msg_type, data):
|
||||
pass
|
||||
|
||||
def sni_cb(sock, servername, ctx):
|
||||
sock.context = server_context2
|
||||
|
||||
server_context._msg_callback = msg_cb
|
||||
server_context.sni_callback = sni_cb
|
||||
|
||||
server = ThreadedEchoServer(context=server_context, chatty=False)
|
||||
with server:
|
||||
with client_context.wrap_socket(socket.socket(),
|
||||
server_hostname=hostname) as s:
|
||||
s.connect((HOST, server.port))
|
||||
with client_context.wrap_socket(socket.socket(),
|
||||
server_hostname=hostname) as s:
|
||||
s.connect((HOST, server.port))
|
||||
|
||||
|
||||
def test_main(verbose=False):
|
||||
if support.verbose:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue