test_https_support fails on Python 3.10
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 778
- Avg merge
- 2h 50m
- Merged PRs (30d)
- 3
Description
**What happened**:
There's not really much in there to explain it so I'm not sure if it's really Python 3.10, or perhaps because of TLS cert verification changes in openssl or something.
```
______________________________ test_https_support ______________________________
c =
s =
a =
b =
@gen_cluster(
client=True,
scheduler_kwargs={"dashboard": True},
config={
"distributed.scheduler.dashboard.tls.key": get_cert("tls-key.pem"),
"distributed.scheduler.dashboard.tls.cert": get_cert("tls-cert.pem"),
"distributed.scheduler.dashboard.tls.ca-file": get_cert("tls-ca-cert.pem"),
},
)
async def test_https_support(c, s, a, b):
port = s.http_server.port
assert (
format_dashboard_link("localhost", port) == "https://localhost:%d/status" % port
)
ctx = ssl.create_default_context()
ctx.load_verify_locations(get_cert("tls-ca-cert.pem"))
http_client = AsyncHTTPClient()
> response = await http_client.fetch(
"https://localhost:%d/individual-plots.json" % port, ssl_options=ctx
)
distributed/dashboard/tests/test_scheduler_bokeh.py:893:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib64/python3.10/site-packages/tornado/simple_httpclient.py:338: in run
stream = await self.tcp_client.connect(
/usr/lib64/python3.10/site-packages/tornado/tcpclient.py:288: in connect
stream = await stream.start_tls(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , server_side = False
ssl_options =
server_hostname = 'localhost'
def start_tls(
self,
server_side: bool,
ssl_options: Optional[Union[Dict[str, Any], ssl.SSLContext]] = None,
server_hostname: Optional[str] = None,
) -> Awaitable["SSLIOStream"]:
"""Convert this `IOStream` to an `SSLIOStream`.
This enables protocols that begin in clear-text mode and
switch to SSL after some initial negotiation (such as the
``STARTTLS`` extension to SMTP and IMAP).
This method cannot be used if there are outstanding reads
or writes on the stream, or if there is any data in the
IOStream's buffer (data in the operating system's socket
buffer is allowed). This means it must generally be used
immediately after reading or writing the last clear-text
data. It can also be used immediately after connecting,
before any reads or writes.
The ``ssl_options`` argument may be either an `ssl.SSLContext`
object or a dictionary of keyword arguments for the
`ssl.wrap_socket` function. The ``server_hostname`` argument
will be used for certificate validation unless disabled
in the ``ssl_options``.
This method returns a `.Future` whose result is the new
`SSLIOStream`. After this method has been called,
any other operation on the original stream is undefined.
If a close callback is defined on this stream, it will be
transferred to the new stream.
.. versionadded:: 4.0
.. versionchanged:: 4.2
SSL certificates are validated by default; pass
``ssl_options=dict(cert_reqs=ssl.CERT_NONE)`` or a
suitably-configured `ssl.SSLContext` to disable.
"""
if (
self._read_future
or self._write_futures
or self._connect_future
or self._closed
or self._read_buffer
or self._write_buffer
):
> raise ValueError("IOStream is not idle; cannot convert to SSL")
E ValueError: IOStream is not idle; cannot convert to SSL
/usr/lib64/python3.10/site-packages/tornado/iostream.py:1270: ValueError
------------------------------ Captured log call -------------------------------
ERROR asyncio:base_events.py:1729 Exception in callback BaseAsyncIOLoop._handle_events(18, 1)
handle:
Traceback (most recent call last):
File "/usr/lib64/python3.10/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "/usr/lib64/python3.10/site-packages/tornado/platform/asyncio.py", line 189, in _handle_events
handler_func(fileobj, events)
File "/usr/lib64/python3.10/site-packages/tornado/netutil.py", line 276, in accept_handler
callback(connection, address)
File "/usr/lib64/python3.10/site-packages/tornado/tcpserver.py", line 288, in _handle_connection
connection = ssl_wrap_socket(
File "/usr/lib64/python3.10/site-packages/tornado/netutil.py", line 615, in ssl_wrap_socket
return context.wrap_socket(socket, server_hostname=server_hostname, **kwargs)
File "/usr/lib64/python3.10/ssl.py", line 512, in wrap_socket
return self.sslsocket_class._create(
File "/usr/lib64/python3.10/ssl.py", line 1061, in _create
self._sslobj = self._context._wrap_socket(
ssl.SSLError: Cannot create a server socket with a PROTOCOL_TLS_CLIENT context (_ssl.c:794)
```
**What you expected to happen**:
Tests pass
**Minimal Complete Verifiable Example**:
`pytest dashboard/tests/test_scheduler_bokeh.py::test_https_support`
**Environment**:
- Dask version: 2021.09.1
- Python version: 3.10
- Operating System: Fedora Rawhide
- Install method (conda, pip, source): Source
Contributor guide
Assessment
This issue has not been assessed yet.