From cbaf9550a4f7d79bd91bcb44f65b5f2d18dfda14 Mon Sep 17 00:00:00 2001 From: ihsan demir Date: Thu, 4 Jan 2024 13:41:05 +0300 Subject: [PATCH] Python 3.12 ssl no longer has the `ssl.wrap_socket` method causes `hazelcast_cloud_discovery_test` failure [API-2195] (#656) * Python 3.12 ssl no longer has the ssl.wrap_socket method but it is replaced with the ssl_context usage. The tests fail at 3.12 build without this fix. --- tests/unit/discovery/hazelcast_cloud_discovery_test.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/unit/discovery/hazelcast_cloud_discovery_test.py b/tests/unit/discovery/hazelcast_cloud_discovery_test.py index d85347f386..85c64b50d3 100644 --- a/tests/unit/discovery/hazelcast_cloud_discovery_test.py +++ b/tests/unit/discovery/hazelcast_cloud_discovery_test.py @@ -73,10 +73,12 @@ class Server: def __init__(self): self.server = HTTPServer((HOST, 0), CloudHTTPHandler) - self.server.socket = ssl.wrap_socket( + ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) + ssl_context.load_cert_chain( + get_abs_path(self.cur_dir, "cert.pem"), get_abs_path(self.cur_dir, "key.pem") + ) + self.server.socket = ssl_context.wrap_socket( self.server.socket, - get_abs_path(self.cur_dir, "key.pem"), - get_abs_path(self.cur_dir, "cert.pem"), server_side=True, ) self.port = self.server.socket.getsockname()[1]