It seems the value of PREFECT_API_TLS_INSECURE_SKIP_VERIFY is not properly propagated to websockets connect.
Reproduced with this code, PREFECT_API_TLS_INSECURE_SKIP_VERIFY=true, and connecting to a secure prefect server under nginx (with self signed certificate):
import asyncio
from prefect.events.clients import PrefectEventsClient
async def main():
async with PrefectEventsClient() as client:
print(f"Connected to: {client._events_socket_url}")
pong = await client._websocket.ping()
pong_time = await pong
print(f"Response received in: {pong_time}")
if __name__ == '__main__':
asyncio.run(main())
The following error is prompted:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "<stdin>", line 2, in main
File "/usr/local/lib/python3.11/dist-packages/prefect/events/clients.py", line 270, in __aenter__
await self._reconnect()
File "/usr/local/lib/python3.11/dist-packages/prefect/events/clients.py", line 288, in _reconnect
self._websocket = await self._connect.__aenter__()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/websockets/legacy/client.py", line 629, in __aenter__
return await self
^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/websockets/legacy/client.py", line 647, in __await_impl_timeout__
return await self.__await_impl__()
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/websockets/legacy/client.py", line 651, in __await_impl__
_transport, _protocol = await self._create_connection()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 1113, in create_connection
transport, protocol = await self._create_connection_transport(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 1146, in _create_connection_transport
await waiter
File "/usr/lib/python3.11/asyncio/sslproto.py", line 578, in _on_handshake_complete
raise handshake_exc
File "/usr/lib/python3.11/asyncio/sslproto.py", line 560, in _do_handshake
self._sslobj.do_handshake()
File "/usr/lib/python3.11/ssl.py", line 979, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate (_ssl.c:1006)
Version info (prefect version output)
Version: 3.0.0
API version: 0.8.4
Python version: 3.11.9
Git commit: c40d069d
Built: Tue, Sep 3, 2024 11:13 AM
OS/Arch: linux/x86_64
Profile: ephemeral
Server type: server
Pydantic version: 2.8.2
Integrations:
prefect-docker: 0.6.0
Bug summary
It seems the value of PREFECT_API_TLS_INSECURE_SKIP_VERIFY is not properly propagated to websockets connect.
Reproduced with this code, PREFECT_API_TLS_INSECURE_SKIP_VERIFY=true, and connecting to a secure prefect server under nginx (with self signed certificate):
The following error is prompted:
Version info (
prefect version
output)Additional context
No response