diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-12-11 10:52:39 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-12-11 11:38:24 +0900 |
commit | dcfc3f60ece50bf478791d644790ea26519bb150 (patch) | |
tree | c8c833e85767e96ea5402a00915b2255002481f2 /tests/utils.py | |
parent | 555e74b8cac015348dcf0e31c3bc22e150508ef5 (diff) | |
download | sphinx-git-dcfc3f60ece50bf478791d644790ea26519bb150.tar.gz |
refactor: ssl.wrap_context() has been deprecated now
Diffstat (limited to 'tests/utils.py')
-rw-r--r-- | tests/utils.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/tests/utils.py b/tests/utils.py index 9430c9beb..1f7cbb05a 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,8 +1,8 @@ import contextlib import http.server import pathlib -import ssl import threading +from ssl import PROTOCOL_TLS_SERVER, SSLContext # Generated with: # $ openssl req -new -x509 -days 3650 -nodes -out cert.pem \ @@ -27,11 +27,9 @@ class HttpServerThread(threading.Thread): class HttpsServerThread(HttpServerThread): def __init__(self, handler, *args, **kwargs): super().__init__(handler, *args, **kwargs) - self.server.socket = ssl.wrap_socket( - self.server.socket, - certfile=CERT_FILE, - server_side=True, - ) + sslcontext = SSLContext(PROTOCOL_TLS_SERVER) + sslcontext.load_cert_chain(CERT_FILE) + self.server.socket = sslcontext.wrap_socket(self.server.socket, server_side=True) def create_server(thread_class): |