This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.2.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/9.2.x by this push:
     new f6840e7c6e Python 3.12: microserver.test.ext wrap_socket update 
(#10247)
f6840e7c6e is described below

commit f6840e7c6e9c890f92370639e7b06770a8538b80
Author: Brian Neradt <[email protected]>
AuthorDate: Thu Aug 17 21:54:47 2023 -0500

    Python 3.12: microserver.test.ext wrap_socket update (#10247)
    
    ssl.wrap_socket was deprecated in Python 3.6 and is removed in Python
    3.12. This patch replaces it with the recommended SSLContext.wrap_socket
    method instead. This fixes the extension for Python 3.12.
    
    (cherry picked from commit 5d4f975fa5934419c3ec6a9e43ba0d3eec316c73)
---
 tests/gold_tests/autest-site/microserver.test.ext | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/tests/gold_tests/autest-site/microserver.test.ext 
b/tests/gold_tests/autest-site/microserver.test.ext
index 554450354e..2ebdf5e186 100644
--- a/tests/gold_tests/autest-site/microserver.test.ext
+++ b/tests/gold_tests/autest-site/microserver.test.ext
@@ -123,10 +123,12 @@ def uServerUpAndRunning(serverHost, port, isSsl, isIPv6, 
request, clientcert='',
         plain_sock = socket.socket(socket.AF_INET)
 
     if isSsl:
+        context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
+        context.check_hostname = False
+        context.verify_mode = ssl.CERT_NONE
         if clientcert != '' or clientkey != '':
-            sock = ssl.wrap_socket(plain_sock, keyfile=clientkey, 
certfile=clientcert)
-        else:
-            sock = ssl.wrap_socket(plain_sock)
+            context.load_cert_chain(certfile=clientcert, keyfile=clientkey)
+        sock = context.wrap_socket(plain_sock)
     else:
         sock = plain_sock
 
@@ -138,11 +140,11 @@ def uServerUpAndRunning(serverHost, port, isSsl, isIPv6, 
request, clientcert='',
             "Connection refused: {0}:{1}".format(
                 serverHost, port))
         return False
-    except ssl.SSLError:
+    except ssl.SSLError as e:
         host.WriteDebug(
             ['uServerUpAndRunning', 'when'],
-            "SSL connection error: {0}:{1}".format(
-                serverHost, port))
+            "SSL connection error: {0}:{1}:{2}".format(
+                serverHost, port, e))
         return False
 
     sock.sendall(request.encode())

Reply via email to