git » chasquid » commit 723c47d

test: Update deprecated ssl.wrap_socket() call

author Alberto Bertogli
2024-10-31 13:09:52 UTC
committer Alberto Bertogli
2024-10-31 13:10:14 UTC
parent a1b6821ce12acbaed40c902763b715cf7f691666

test: Update deprecated ssl.wrap_socket() call

ssl.wrap_socket() has been deprecated and is no longer functional in
Python 3.12: https://docs.python.org/3/whatsnew/3.12.html#ssl.

This patch replaces it with the equivalent (in this context)
ssl.SSLContext.

test/util/chamuyero +5 -1

diff --git a/test/util/chamuyero b/test/util/chamuyero
index fa74b8a..24d49f6 100755
--- a/test/util/chamuyero
+++ b/test/util/chamuyero
@@ -113,7 +113,11 @@ class TLSSock (Sock):
         host, port = addr.rsplit(":", 1)
         Sock.__init__(self, (host, int(port)))
         plain_sock = socket.create_connection(self.addr)
-        self.sock = ssl.wrap_socket(plain_sock)
+
+        context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
+        context.check_hostname = False
+        context.verify_mode = ssl.CERT_NONE
+        self.sock = context.wrap_socket(plain_sock)
 
     def connect(self):
         self.connr = self.sock.makefile(mode="r", encoding="utf8")