Skip to content

feat(studio): allow TLS certs from environment - #17648

Merged
danielhanchen merged 4 commits into
unslothai:mainfrom
bezabyte:codex/issue-17640-ssl-env
Nov 14, 2026
Merged

danielhanchen merged 4 commits into
unslothai:mainfrom
bezabyte:codex/issue-17640-ssl-env

Conversation

@bezabyte

@bezabyte bezabyte commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Closes #17640

What changed

  • unsloth studio reads UNSLOTH_STUDIO_SSL_CERTFILE and UNSLOTH_STUDIO_SSL_KEYFILE when neither --ssl-certfile nor --ssl-keyfile is passed, so Docker and systemd launches can serve HTTPS without extra command-line arguments. Passing either flag ignores the variables.
  • The pair is resolved and validated in the CLI before the password gate, like the flags: a half pair, an unreadable or mismatched pair, or a pair combined with --secure / --cloudflare exits 2 naming the variables, before any credential is touched.
  • The Desktop-owned backend ignores the variables (its shell talks plain HTTP to it), and run_server stays argument-only, so unsloth run, unsloth studio run, Colab and embedders are unchanged.
  • Docker: docker/run.sh forwards both variables; the Studio ready probe, the unsloth-studio-update health wait and the startup banners switch to https:// (probes use curl -k, since the certificate names the host rather than 127.0.0.1) when both are set.
  • README and DOCKERHUB.md document the variables.

Validation

  • unsloth_cli/tests/test_studio_tls_flags.py: env pair forwarded, bad env pairs fail before the password gate, flags replace the env pair, Desktop backend ignores it (14 passed; the new env cases fail with the fallback disabled).
  • tests/python/test_docker_*: 931 passed, including a probe/banner test that fails without the script change.
  • End to end on a real Studio install with a self-signed certificate: the env pair serves HTTPS (https + -k probe 0, old http probe curl 52), no env or the Desktop marker stays on HTTP, and a half pair or --secure exits 2 before auth.db is created.

@danielhanchen danielhanchen self-assigned this Nov 13, 2026
Resolve UNSLOTH_STUDIO_SSL_CERTFILE / UNSLOTH_STUDIO_SSL_KEYFILE in
`unsloth studio` only when neither flag is given, so a bad or half pair
fails before credentials are touched, and skip it for the Desktop-owned
backend, which talks plain HTTP. run_server stays argument-only, so
`unsloth run`, Colab and embedders are unaffected.

[skip ci]
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T07:26:54.797976Z 68b4957 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b2e07c6cf6

ℹ️ 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".

Comment thread docker/run.sh
Comment on lines +360 to +361
[[ -n "${UNSLOTH_STUDIO_SSL_CERTFILE:-}" ]] && ENV_FORWARD+=(-e UNSLOTH_STUDIO_SSL_CERTFILE)
[[ -n "${UNSLOTH_STUDIO_SSL_KEYFILE:-}" ]] && ENV_FORWARD+=(-e UNSLOTH_STUDIO_SSL_KEYFILE)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make Docker health probes honor the TLS mode

With both variables set for the standard Docker launch, Studio serves HTTPS on UNSLOTH_STUDIO_PORT, but docker/studio_password.sh:79 and docker/unsloth_studio_update.sh:580 still probe http://127.0.0.1:<port>/api/health (curl --manual, PROTOCOLS: “protocols, or put in URL terms: schemes”). The plain-HTTP self-call listener uses a separate ephemeral port (studio/backend/run.py:2610-2613), so it cannot satisfy either probe. Consequently, readiness reports a healthy service as unavailable, and a normal unsloth-studio-update times out and invokes back_out at line 588, rolling back a healthy update. Make these Docker probes TLS-aware alongside enabling the new environment variables.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7c37310: the Studio ready probe, the unsloth-studio-update health wait and both banners switch to https (curl -k) when both TLS variables are set.

…r is set

With UNSLOTH_STUDIO_SSL_CERTFILE and UNSLOTH_STUDIO_SSL_KEYFILE set, Studio
serves HTTPS on its port, so the ready probe, unsloth-studio-update's health
wait (which rolled a healthy update back) and the banners used plain HTTP.

[skip ci]
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 7c37310dfa

ℹ️ 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".

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 68b49575f2

ℹ️ 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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] set ssl certfile and keyfile from config file or environment

3 participants