Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Commit 3669bc3

Browse files
committed
novnc: add encrypt parameter
Add encrypt parameter to novnc adapter class, so that it can be configured in the url params. This allows the VNC driver to set --encrypt/--no-encrypt parameter through command line (default False) for more flexibility on the type of connection the user needs. Signed-off-by: Albert Esteve <aesteve@redhat.com>
1 parent 5da9de0 commit 3669bc3

3 files changed

Lines changed: 27 additions & 7 deletions

File tree

  • packages
    • jumpstarter-driver-network/jumpstarter_driver_network/adapters
    • jumpstarter-driver-vnc

packages/jumpstarter-driver-network/jumpstarter_driver_network/adapters/novnc.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
@blocking
1212
@asynccontextmanager
13-
async def NovncAdapter(*, client: DriverClient, method: str = "connect"):
13+
async def NovncAdapter(*, client: DriverClient, method: str = "connect", encrypt: bool = False):
1414
async def handler(conn):
1515
async with conn:
1616
async with client.stream_async(method) as stream:
@@ -19,13 +19,23 @@ async def handler(conn):
1919
pass
2020

2121
async with TemporaryTcpListener(handler) as addr:
22+
scheme = "https" if encrypt else "http"
23+
params = {
24+
"autoconnect": 1,
25+
"reconnect": 1,
26+
"host": addr[0],
27+
"port": addr[1],
28+
}
29+
if not encrypt:
30+
params["encrypt"] = 0
31+
2232
yield urlunparse(
2333
(
24-
"https",
34+
scheme,
2535
"novnc.com",
2636
"/noVNC/vnc.html",
2737
"",
28-
urlencode({"autoconnect": 1, "reconnect": 1, "host": addr[0], "port": addr[1]}),
38+
urlencode(params),
2939
"",
3040
)
3141
)

packages/jumpstarter-driver-vnc/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,9 @@ j vnc session
5555
5656
# To prevent it from opening a browser automatically:
5757
j vnc session --no-browser
58+
59+
# To use an encrypted (wss://) connection (requires a trusted certificate):
60+
j vnc session --encrypt
5861
```
62+
63+
> **Note:** Using `--encrypt` is intended for advanced scenarios where the local proxy can be configured with a TLS certificate that your browser trusts. For standard local development, modern browsers will likely reject the self-signed certificate and the connection will fail.

packages/jumpstarter-driver-vnc/jumpstarter_driver_vnc/client.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ def tcp(self) -> TCPClient:
2525
return typing.cast("TCPClient", self.children["tcp"])
2626

2727
@contextlib.contextmanager
28-
def session(self) -> typing.Iterator[str]:
28+
def session(self, *, encrypt: bool = False) -> typing.Iterator[str]:
2929
"""Create a new VNC session."""
30-
with NovncAdapter(client=self.tcp, method="connect") as adapter:
30+
with NovncAdapter(client=self.tcp, method="connect", encrypt=encrypt) as adapter:
3131
yield adapter
3232

3333
def cli(self) -> click.Command:
@@ -39,12 +39,17 @@ def vnc():
3939

4040
@vnc.command()
4141
@click.option("--browser/--no-browser", default=True, help="Open the session in a web browser.")
42-
def session(browser: bool):
42+
@click.option(
43+
"--encrypt/--no-encrypt",
44+
default=False,
45+
help="Use an encrypted connection (wss://).",
46+
)
47+
def session(browser: bool, encrypt: bool):
4348
"""Open a VNC session."""
4449
# The NovncAdapter is a blocking context manager that runs in a thread.
4550
# We can enter it, open the browser, and then just wait for the user
4651
# to press Ctrl+C to exit. The adapter handles the background work.
47-
with self.session() as url:
52+
with self.session(encrypt=encrypt) as url:
4853
click.echo(f"To connect, please visit: {url}")
4954
if browser:
5055
webbrowser.open(url)

0 commit comments

Comments
 (0)