Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio engines: verify TLS against Studio's certifi bundle (#15509)
Daniel Han1cb33f7666c4
diff --git a/studio/backend/core/inference/managed_engine.py b/studio/backend/core/inference/managed_engine.pyindex 175f4cd8785..7607f01daaf 100644--- a/studio/backend/core/inference/managed_engine.py+++ b/studio/backend/core/inference/managed_engine.py@@ -73,6 +73,24 @@ def _mig_rows(gpu_ids: list[int]):return None+_CA_BUNDLE_VARIABLES = ("SSL_CERT_FILE", "SSL_CERT_DIR", "REQUESTS_CA_BUNDLE", "CURL_CA_BUNDLE")+++def _point_tls_at_studio_ca_bundle(child_env: dict[str, str]) -> None:+ """Engines verify TLS with Studio's current certifi unless the user chose a bundle: their+ hash-pinned venvs keep an old certifi (2026.7.22 still trusts the revoked emSign roots)."""+ if any(child_env.get(name) for name in _CA_BUNDLE_VARIABLES):+ return+ try:+ import certifi+ bundle = certifi.where()+ except Exception:+ return+ if os.path.isfile(bundle):+ child_env["SSL_CERT_FILE"] = bundle+ child_env["REQUESTS_CA_BUNDLE"] = bundle++def _child_cuda_mask(gpu_ids: list[int]) -> str:"""Instance UUIDs on an R570+ MIG host (numeric ids would name the whole host), else the numeric mask."""try:@@ -716,6 +734,7 @@ class ManagedEngine:if rocm:child_env.update(_rocm_visibility(child_env, gpu_ids or [0]))child_env["PYTHONNOUSERSITE"] = "1"+ _point_tls_at_studio_ca_bundle(child_env)from .engine_install import engine_rootcache = (diff --git a/studio/backend/tests/test_managed_engine_ca_bundle.py b/studio/backend/tests/test_managed_engine_ca_bundle.pynew file mode 100644index 00000000000..3343ae8e87a--- /dev/null+++ b/studio/backend/tests/test_managed_engine_ca_bundle.py@@ -0,0 +1,44 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-Present the Unsloth team. See /studio/LICENSE.AGPL-3.0++"""A launched engine verifies TLS against Studio's certifi bundle, not the one its lock pinned."""++from __future__ import annotations++import inspect++import certifi+import pytest++from core.inference import managed_engine+++def test_an_engine_without_a_chosen_bundle_gets_studios_certifi():+ env = {"PATH": "/usr/bin"}+ managed_engine._point_tls_at_studio_ca_bundle(env)+ assert env["SSL_CERT_FILE"] == certifi.where()+ assert env["REQUESTS_CA_BUNDLE"] == certifi.where()+ before = dict(env)+ managed_engine._point_tls_at_studio_ca_bundle(env)+ assert env == before+++ "name", ["SSL_CERT_FILE", "SSL_CERT_DIR", "REQUESTS_CA_BUNDLE", "CURL_CA_BUNDLE"]+)+def test_a_bundle_the_user_chose_is_left_alone(name):+ env = {name: "/etc/corp/ca.pem"}+ managed_engine._point_tls_at_studio_ca_bundle(env)+ assert env == {name: "/etc/corp/ca.pem"}+++def test_a_missing_bundle_file_sets_nothing(monkeypatch, tmp_path):+ monkeypatch.setattr(certifi, "where", lambda: str(tmp_path / "gone.pem"))+ env = {}+ managed_engine._point_tls_at_studio_ca_bundle(env)+ assert env == {}+++def test_the_local_launch_applies_it():+ source = inspect.getsource(managed_engine)+ assert source.count("_point_tls_at_studio_ca_bundle(child_env)") == 1