From 61dede72f91ce01697b4b533f554f5ed8f4a03ad Mon Sep 17 00:00:00 2001 From: grossmj Date: Fri, 3 Nov 2023 15:35:49 +1000 Subject: [PATCH] Fix ws console and packet capture over SSL --- gns3server/api/routes/controller/links.py | 2 ++ gns3server/api/routes/controller/nodes.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gns3server/api/routes/controller/links.py b/gns3server/api/routes/controller/links.py index 618ea198..7264a941 100644 --- a/gns3server/api/routes/controller/links.py +++ b/gns3server/api/routes/controller/links.py @@ -267,11 +267,13 @@ async def stream_pcap(request: Request, link: Link = Depends(dep_link)) -> Strea async def compute_pcap_stream(): try: + ssl_context = Controller.instance().ssl_context() async with HTTPClient.request( request.method, pcap_streaming_url, user=compute.user, password=compute.password, + ssl_context=ssl_context, timeout=None, data=body ) as response: diff --git a/gns3server/api/routes/controller/nodes.py b/gns3server/api/routes/controller/nodes.py index 13e84450..f9cac15b 100644 --- a/gns3server/api/routes/controller/nodes.py +++ b/gns3server/api/routes/controller/nodes.py @@ -541,7 +541,7 @@ async def ws_console( pass ws_console_compute_url = ( - f"ws://{compute_host}:{compute.port}/v3/compute/projects/" + f"{websocket.url.scheme}://{compute_host}:{compute.port}/v3/compute/projects/" f"{node.project.id}/{node.node_type}/nodes/{node.id}/console/ws" ) @@ -575,7 +575,8 @@ async def ws_console( auth = aiohttp.BasicAuth(user, password.get_secret_value(), "utf-8") else: auth = aiohttp.BasicAuth(user, "") - async with HTTPClient.get_client().ws_connect(ws_console_compute_url, auth=auth) as ws: + ssl_context = Controller.instance().ssl_context() + async with HTTPClient.get_client().ws_connect(ws_console_compute_url, auth=auth, ssl_context=ssl_context) as ws: asyncio.ensure_future(ws_receive(ws)) async for msg in ws: if msg.type == aiohttp.WSMsgType.TEXT: