[Test] Use `ssl.SSLContext.wrap_socket`, not `ssl.wrap_socket` (#33492)

In the HTTP(S) test server in the core tests, use
`ssl.SSLContext.wrap_socket`, not `ssl.wrap_socket`. The latter emits a
`DeprecationWarning` since Python 3.10 and is [removed in Python
3.12](https://github.com/python/cpython/issues/94199).

This fixes the core tests (but not necessarily the `grpcio` tests) for
Python 3.12.

This is relevant to https://github.com/grpc/grpc/issues/33063.
pull/33508/head
Ben Beasley 1 year ago committed by GitHub
parent e9c44836bc
commit 011e1162c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      test/core/http/test_server.py

@ -71,7 +71,7 @@ class Handler(BaseHTTPRequestHandler):
httpd = HTTPServer(("localhost", args.port), Handler)
if args.ssl:
httpd.socket = ssl.wrap_socket(
httpd.socket, certfile=_PEM, keyfile=_KEY, server_side=True
)
ctx = ssl.SSLContext()
ctx.load_cert_chain(certfile=_PEM, keyfile=_KEY)
httpd.socket = ctx.wrap_socket(httpd.socket, server_side=True)
httpd.serve_forever()

Loading…
Cancel
Save