Repository navigation
Studio: serve HTTPS from your own certificate (--ssl-certfile / --ssl-keyfile) - #13447
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1fa7ee6af2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| self.loopback_http = await asyncio.get_running_loop().create_server( | ||
| _protocol, host = "127.0.0.1", port = 0, backlog = config.backlog |
There was a problem hiding this comment.
Use an IPv6 loopback for IPv6-only TLS launches
For a TLS launch bound to :: or ::1 on an IPv6-only host, startup still unconditionally creates the required plaintext self-call listener on 127.0.0.1. If IPv4 is disabled or unavailable, this bind fails after the public TLS socket has started and aborts an otherwise valid IPv6 launch. Select the loopback family from the requested bind (and publish that host alongside the ephemeral port) instead of requiring IPv4 for every TLS launch.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this: it needs a host with the IPv4 loopback removed, which Linux, macOS and Windows all keep even on IPv6-only networks.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e82ece1ad7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for address in addresses: | ||
| url_host = f"[{address}]" if ":" in address else address | ||
| urls.append(f"http://{url_host}:{port}") | ||
| urls.append(f"{scheme}://{url_host}:{port}") |
There was a problem hiding this comment.
Do not advertise certificate-invalid LAN IP URLs
With a DNS-only certificate such as the documented Tailscale or Let's Encrypt examples, a wildcard or Settings-managed LAN listener reaches this formatter with literal LAN addresses and now publishes URLs such as https://192.168.1.5:8888; the LAN panel exposes these through its Copy and QR actions, but browsers reject them because the IP is absent from the certificate SANs. Although server_url is now suppressed for TLS launches, _launch_urls still calls this changed formatter, so the panel should retain a certificate-valid/request hostname or omit these literal-IP URLs rather than changing their scheme to HTTPS.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Keeping these: the IP URL is the right address for certificates with IP SANs (self-signed, internal CA), and for DNS-only certificates Studio cannot know which hostname the user reaches it by. Dropping them would hide where the listener answers.
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
| client = ssl.create_default_context(cafile = str(crt)) | ||
| try: | ||
| with socket.create_connection(("127.0.0.1", port), timeout = 10) as raw: | ||
| with client.wrap_socket(raw, server_hostname = "studio.example.ts.net") as tls: |
# Conflicts: # unsloth_cli/commands/studio.py
|
pre-commit.ci run |
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Fixes #8716
What this adds
unsloth studiocan now serve HTTPS itself from a certificate and key you already have, for example the*.ts.netpair fromtailscale cert, a Let's Encrypt certificate, or an internal CA:The banner and the Settings > LAN access URLs switch to
https://. A TLS launch does not publish an IP-basedserver_url: certificates such astailscale certname a DNS host, so the API examples and copied links use the origin the browser actually reached. Nothing changes for a launch without these flags: the code path is identical (sameuvicorn.Config, same listeners, same banner text).Behaviour
--ssl-certfile and --ssl-keyfile must be passed together.KEY_VALUES_MISMATCH)--secureor--cloudflareunsloth studio run --ssl-certfile ...Implementation notes
truststoreintossl(default on for macOS, Windows and the desktop-owned Linux backend). The injectedSSLContextverifies the peer chain against the OS store on every handshake, and on a server the peer is the browser, which sends no certificate, so truststore raises (Peer sent no certificates to verifyon Windows).utils/studio_tls.pybuilds the server context from the injected class (uvloop checksisinstanceagainst it) and resets only itssslobject_classhook back tossl.SSLObject.test_native_tls_entrypoints.pynow checks with an AST walk that any TLS server context or uvicorn cert kwargs go through that module./v1from children that cannot be told to trust a private certificate. A TLS launch therefore also listens for plain HTTP on an ephemeral127.0.0.1port (same uvicorn server, lifespan and connection drain, kept out ofserver.serversso the published port and host are unchanged), and those call sites use it. This is the same loopback exposure every default launch has today.https://<bound host>:<port>.Testing
studio/backend/tests/test_studio_tls.py(new): pair validation; a real HTTPS handshake through uvicorn with truststore injected and the macOS / Windows empty-chain behaviour reproduced, plus a negative control showing stockuvicorn.Config(ssl_certfile=...)fails under the same injection; banner URLs; LAN listener config; self-call port lookup. The handshake test fails if the hook reset is removed.studio.example.ts.netwith LAN IP SANs, results in the table below.unsloth studio -H 127.0.0.1 --ssl-certfile ... --ssl-keyfile ...GET /200,/api/health200, login 200, change-password 200 over HTTPS; plain HTTP to the same port: connection closed127.0.0.1only,/api/health200 over HTTPrun.py --host 0.0.0.0+ both flagsCould not load the TLS certificate and key (...): [X509: KEY_VALUES_MISMATCH] key values mismatch--secure+ both flags--ssl-certfile/--ssl-keyfile serve HTTPS directly; do not combine them with --secure or --cloudflare.Related tests (77 files touching the banner, LAN / remote access, data recipes, research runs, native TLS, CLI flags) give the same pass/fail set on this branch and on the merge base, apart from the new tests.