testenv: fix for Python 3.12

* testenv/server/http/http_server.py (HTTPSServer): Update for
  ssl.SSLContext APIs instead of deprecated ssl.wrap_socket().

ssl.wrap_socket() was deprecated in 3.7 and removed in 3.12.
This should be compatible back to 3.6 (RHEL 8 and newer).

Copyright-paperwork-exempt: Yes
This commit is contained in:
Yaakov Selkowitz 2023-07-12 18:04:37 -04:00 committed by Tim Rühsen
parent 3583fa0c61
commit 9c8668048d

View File

@ -47,10 +47,10 @@ class HTTPSServer(StoppableHTTPServer):
os.getenv('srcdir', '.'),
'certs',
'server-key.pem'))
self.socket = ssl.wrap_socket(
ctx = ssl.SSLContext(protocol=ssl.PROTOCOL_TLS_SERVER)
ctx.load_cert_chain(CERTFILE, KEYFILE)
self.socket = ctx.wrap_socket(
sock=socket.socket(self.address_family, self.socket_type),
certfile=CERTFILE,
keyfile=KEYFILE,
server_side=True
)
self.server_bind()