Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

tls: downloads check the server against the operating system's certificates; a failed check gives a plain message (#3722)

Niko1221c4aec611b200
diff --git a/apps/host/server/agent/harness-runtime.mjs b/apps/host/server/agent/harness-runtime.mjs
index 078c6cb4b..d043d5589 100644
--- a/apps/host/server/agent/harness-runtime.mjs
+++ b/apps/host/server/agent/harness-runtime.mjs
@@ -33,7 +33,7 @@ export function agentEnvironment(base = process.env, extra = {}) {
}
// DSH_PERMISSION_MODE is the composition default for a session no chat mode has touched (a child agent, a
// seeded session): the strictest sandbox, which matches the Manual preset, never the Harness's wider default.
- return { ...out, DSH_TELEMETRY_DISABLED: '1', DSH_PERMISSION_MODE: 'read-only', ...extra };
+ return { ...out, DSH_TELEMETRY_DISABLED: '1', DSH_PERMISSION_MODE: 'read-only', NODE_USE_SYSTEM_CA: '1', ...extra };
}
/**
diff --git a/apps/host/server/index.mjs b/apps/host/server/index.mjs
index 68d69b605..3fb6e8420 100644
--- a/apps/host/server/index.mjs
+++ b/apps/host/server/index.mjs
@@ -1,4 +1,5 @@
#!/usr/bin/env node
+import './system-ca.mjs'; // #3722: the operating system's certificates, before any HTTPS request
import { createCloudflare } from './cloudflare.mjs';
import { createConnectorInstaller } from './cloudflared-install.mjs';
import { findRunningConnector } from './cloudflared-find.mjs';
diff --git a/apps/host/server/system-ca.mjs b/apps/host/server/system-ca.mjs
new file mode 100644
index 000000000..b0d093c74
--- /dev/null
+++ b/apps/host/server/system-ca.mjs
@@ -0,0 +1,24 @@
+// The host's own HTTPS downloads (engine releases from GitHub, web search, a cloud model's API) check the server against the operating
+// system's certificates as well as Node's bundled list (#3722). Node carries its own list of roots; Chrome and curl.exe use the Windows
+// store, which also holds the roots an antivirus's HTTPS scanning, a company proxy or an OS preview build adds. Nothing is turned off:
+// the system roots are ADDED to the bundled ones, and a connection that still fails keeps failing.
+//
+// Node 24.5 and newer: tls.getCACertificates('system') and tls.setDefaultCACertificates. An older Node (the app bundles 24.x) does nothing here;
+// the agent process gets NODE_USE_SYSTEM_CA=1 (harness-runtime.mjs) for the same reason.
+import tlsModule from 'node:tls';
+
+/** @returns {'system'|'bundled'} what the process trusts after the call */
+export function useSystemCertificates(tls = tlsModule, env = process.env) {
+ if (env.STRATA_NO_SYSTEM_CA === '1') return 'bundled'; // a way back for a PC where reading the store misbehaves; not a way to skip checks
+ try {
+ if (typeof tls.getCACertificates !== 'function' || typeof tls.setDefaultCACertificates !== 'function') return 'bundled';
+ const system = tls.getCACertificates('system');
+ if (!Array.isArray(system) || !system.length) return 'bundled';
+ tls.setDefaultCACertificates([...new Set([...tls.getCACertificates('bundled'), ...system])]);
+ return 'system';
+ } catch {
+ return 'bundled';
+ }
+}
+
+export const trust = useSystemCertificates();
diff --git a/apps/host/tests/agent-events.test.mjs b/apps/host/tests/agent-events.test.mjs
index ea0c5f077..bacba9193 100644
--- a/apps/host/tests/agent-events.test.mjs
+++ b/apps/host/tests/agent-events.test.mjs
@@ -60,7 +60,7 @@ test('routeFor picks the chat\'s own choice', () => {
test('the agent environment keeps what a shell needs and drops ambient credentials', () => {
const env = agentEnvironment({ PATH: '/bin', HOME: '/h', OPENAI_API_KEY: 'x', GITHUB_TOKEN: 'y', AWS_SECRET_ACCESS_KEY: 'z', SSH_AUTH_SOCK: 's', SystemRoot: 'C:\\Windows' }, { STRATA_API_KEY_X: 'k' });
- assert.deepEqual(Object.keys(env).sort(), ['DSH_PERMISSION_MODE', 'DSH_TELEMETRY_DISABLED', 'HOME', 'PATH', 'STRATA_API_KEY_X', 'SystemRoot']);
+ assert.deepEqual(Object.keys(env).sort(), ['DSH_PERMISSION_MODE', 'DSH_TELEMETRY_DISABLED', 'HOME', 'NODE_USE_SYSTEM_CA', 'PATH', 'STRATA_API_KEY_X', 'SystemRoot']);
});
test('redact removes secret values and launch tokens from log text', () => {
diff --git a/apps/host/tests/system-ca.test.mjs b/apps/host/tests/system-ca.test.mjs
new file mode 100644
index 000000000..92f2158c6
--- /dev/null
+++ b/apps/host/tests/system-ca.test.mjs
@@ -0,0 +1,42 @@
+// #3722: the host trusts the operating system's certificates in addition to Node's bundled list, and only adds to it.
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { useSystemCertificates } from '../server/system-ca.mjs';
+import { agentEnvironment } from '../server/agent/harness-runtime.mjs';
+
+const fake = (system, bundled = ['B1', 'B2']) => {
+ const calls = [];
+ return { calls, getCACertificates: kind => (kind === 'system' ? system : bundled), setDefaultCACertificates: list => calls.push(list) };
+};
+
+test('system roots are added to the bundled ones', () => {
+ const tls = fake(['S1', 'B1']);
+ assert.equal(useSystemCertificates(tls, {}), 'system');
+ assert.deepEqual(tls.calls, [['B1', 'B2', 'S1']]);
+});
+
+test('an empty or unreadable system store, or an older Node, changes nothing and never throws', () => {
+ const empty = fake([]);
+ assert.equal(useSystemCertificates(empty, {}), 'bundled');
+ assert.equal(empty.calls.length, 0);
+ assert.equal(useSystemCertificates({}, {}), 'bundled');
+ assert.equal(useSystemCertificates({ getCACertificates() { throw new Error('store'); }, setDefaultCACertificates() {} }, {}), 'bundled');
+});
+
+test('STRATA_NO_SYSTEM_CA=1 leaves Node as it was', () => {
+ const tls = fake(['S1']);
+ assert.equal(useSystemCertificates(tls, { STRATA_NO_SYSTEM_CA: '1' }), 'bundled');
+ assert.equal(tls.calls.length, 0);
+});
+
+test('the real Node of this machine can read its system store', () => {
+ const tls = process.getBuiltinModule?.('node:tls');
+ if (typeof tls?.getCACertificates !== 'function') return;
+ assert.ok(Array.isArray(tls.getCACertificates('system')));
+});
+
+test('the agent process is started with NODE_USE_SYSTEM_CA=1, and no switch turns verification off', () => {
+ const env = agentEnvironment({ PATH: 'x' }, {});
+ assert.equal(env.NODE_USE_SYSTEM_CA, '1');
+ assert.ok(!('NODE_TLS_REJECT_UNAUTHORIZED' in env));
+});
diff --git a/packaging/locks/runtime-darwin-arm64-cp312.txt b/packaging/locks/runtime-darwin-arm64-cp312.txt
index 4094cd881..a60b44822 100644
--- a/packaging/locks/runtime-darwin-arm64-cp312.txt
+++ b/packaging/locks/runtime-darwin-arm64-cp312.txt
@@ -42,6 +42,8 @@ textual==8.2.8 \
--hash=sha256:267375fd402dc8d981457212efa71f0e3365fd17bba144ba9bb3ed7563cb374a
tqdm==4.70.1 \
--hash=sha256:c293e525e6fef9c20e8728fd4612df02a0aa31bb5fe91ecd93e123b1b7bffa73
+truststore==0.10.5 \
+ --hash=sha256:9aaaedaefaf06d8b206278cf8b5012bc897f485a874503501e12d776df78951c
typing-extensions==4.16.0 \
--hash=sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8
urllib3==2.8.0 \
diff --git a/packaging/locks/runtime-linux-x86_64-cp312.txt b/packaging/locks/runtime-linux-x86_64-cp312.txt
index a2014bfd4..d1fe6e648 100644
--- a/packaging/locks/runtime-linux-x86_64-cp312.txt
+++ b/packaging/locks/runtime-linux-x86_64-cp312.txt
@@ -42,6 +42,8 @@ textual==8.2.8 \
--hash=sha256:267375fd402dc8d981457212efa71f0e3365fd17bba144ba9bb3ed7563cb374a
tqdm==4.70.1 \
--hash=sha256:c293e525e6fef9c20e8728fd4612df02a0aa31bb5fe91ecd93e123b1b7bffa73
+truststore==0.10.5 \
+ --hash=sha256:9aaaedaefaf06d8b206278cf8b5012bc897f485a874503501e12d776df78951c
typing-extensions==4.16.0 \
--hash=sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8
urllib3==2.8.0 \
diff --git a/packaging/locks/runtime-windows-x86_64-cp312.txt b/packaging/locks/runtime-windows-x86_64-cp312.txt
index 8d82608db..e3870fc95 100644
--- a/packaging/locks/runtime-windows-x86_64-cp312.txt
+++ b/packaging/locks/runtime-windows-x86_64-cp312.txt
@@ -44,6 +44,8 @@ textual==8.2.8 \
--hash=sha256:267375fd402dc8d981457212efa71f0e3365fd17bba144ba9bb3ed7563cb374a
tqdm==4.70.1 \
--hash=sha256:c293e525e6fef9c20e8728fd4612df02a0aa31bb5fe91ecd93e123b1b7bffa73
+truststore==0.10.5 \
+ --hash=sha256:9aaaedaefaf06d8b206278cf8b5012bc897f485a874503501e12d776df78951c
typing-extensions==4.16.0 \
--hash=sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8
urllib3==2.8.0 \
diff --git a/requirements.txt b/requirements.txt
index 19a0ce8de..903773a12 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -16,6 +16,7 @@ psutil==7.2.2
# their dependencies
markupsafe==3.0.3
certifi==2026.10.19
+truststore==0.10.5; python_version >= "3.10"
charset-normalizer==3.5.1
idna==3.20
urllib3==2.8.0
diff --git a/serve/server.py b/serve/server.py
index 171e68606..f192f1b1d 100644
--- a/serve/server.py
+++ b/serve/server.py
@@ -66,6 +66,9 @@ from serve.frontend import (THINK_END, ChatTemplate, Event, OutputParser, anthro
from serve.mcp import McpCancelled, hub_from_config # noqa: E402
from serve import runconfig # noqa: E402
from strata_control import engine_component # noqa: E402
+from strata_control import tls # noqa: E402
+
+tls.install() # #3722: image URLs and tool servers over HTTPS are checked against the operating system's certificates
from strata_control import hipblaslt_tuning # noqa: E402
from strata_control import vision_reader # noqa: E402
from strata_control import draft_layer # noqa: E402
diff --git a/setup.py b/setup.py
index bf800d3c3..9e63f694a 100644
--- a/setup.py
+++ b/setup.py
@@ -63,6 +63,9 @@ import zipfile
from pathlib import Path
from strata_control import acquisition
+from strata_control import tls
+
+tls.install() # #3722: HTTPS checks the server against the operating system's certificates (what Chrome and curl.exe do)
from strata_control import atomic
from strata_control import draft_layer
from strata_control.discovery import in_trash
@@ -741,7 +744,12 @@ def _urlopen(req, timeout=None):
"""Every network request of this file goes through here: starting and serving never reach the network
(strata_control/acquisition.py), only an explicit setup, update or install does."""
acquisition.require("a download")
- return urllib.request.urlopen(req, timeout=timeout)
+ try:
+ return urllib.request.urlopen(req, timeout=timeout)
+ except urllib.error.URLError as e:
+ if tls.is_certificate_error(e): # not the raw urlopen text, and never a way to skip the check
+ raise tls.CertificateProblem(tls.host_of(req.full_url if hasattr(req, "full_url") else str(req))) from None
+ raise
def run(cmd, cwd=None, env=None, check=True, quiet=False):
@@ -2667,6 +2675,8 @@ def download(url, dst: Path, what=None):
fail(f"cannot reach {url.split('/')[2]} ({e})",
"check your internet connection and run it again" + source_hint(url))
time.sleep(5)
+ except tls.CertificateProblem as e: # the same answer five times: no retry
+ fail(f"cannot download from {url.split('/')[2]}: its security certificate was not accepted", str(e))
except OSError as e:
if attempt == 4:
fail(f"cannot reach {url.split('/')[2]} ({e})",
diff --git a/strata_control/components.py b/strata_control/components.py
index 8d6665ffd..d39ddbf29 100644
--- a/strata_control/components.py
+++ b/strata_control/components.py
@@ -532,6 +532,8 @@ class ComponentStore:
acquisition.require(f"the download of {artifact.name}", "strata install")
import urllib.error
import urllib.request
+ from strata_control import tls
+ tls.install()
partial = self.root / "partial" / artifact.name
have = partial.stat().st_size if partial.exists() else 0
if have > artifact.bytes:
@@ -553,6 +555,8 @@ class ComponentStore:
break
out.write(block)
except (urllib.error.URLError, OSError) as e:
+ if tls.is_certificate_error(e):
+ raise ComponentError(f"the download of {artifact.name} stopped. " + tls.explain(tls.host_of(artifact.url))) from e
raise ComponentError(
f"the download of {artifact.name} was interrupted after "
f"{partial.stat().st_size if partial.exists() else 0} of {artifact.bytes} bytes; "
diff --git a/strata_control/tls.py b/strata_control/tls.py
new file mode 100644
index 000000000..8c27ee54a
--- /dev/null
+++ b/strata_control/tls.py
@@ -0,0 +1,88 @@
+"""How Strata's own programs check the certificate of a server they download from (#3722).
+
+Python's OpenSSL checks a server against a list of root certificates it carries (certifi) and does not fetch a missing intermediate
+certificate. Chrome and curl.exe use the operating system's certificate store and its chain building (Windows schannel, macOS Security,
+the system bundle on Linux): they also trust the roots that antivirus HTTPS scanning, a company proxy or a Windows Insider build adds
+there, and they fetch a missing intermediate from the address inside the certificate. So a PC where the browser works could still
+fail with CERTIFICATE_VERIFY_FAILED ("unable to get local issuer certificate") in Strata.
+
+`install()` makes every later HTTPS connection of this process use the operating system's store, through the `truststore` package
+(pure Python, Python 3.10 and newer, pinned in requirements.txt and the runtime locks). Where it is not installed (an older Python, a
+checkout that has not installed the pins yet) the certifi list is used; where that is missing too, Python's own default stays.
+Verification is never turned off: a connection that still fails is explained by `explain()`, and nothing here offers to skip the check.
+"""
+
+from __future__ import annotations
+
+import ssl
+import sys
+
+#: "truststore", "certifi" or "default": what the process uses after install()
+mode: str | None = None
+
+
+def install() -> str:
+ """Use the OS certificate store for every HTTPS connection of this process. Safe to call again and from any thread's start."""
+ global mode
+ if mode is not None:
+ return mode
+ try:
+ import truststore # Python >= 3.10
+ truststore.inject_into_ssl()
+ mode = "truststore"
+ return mode
+ except Exception: # ImportError, or a Python/OS truststore cannot work on
+ pass
+ try:
+ import certifi
+ bundle = certifi.where()
+ ssl._create_default_https_context = lambda *a, **k: ssl.create_default_context(cafile=bundle) # type: ignore[assignment]
+ mode = "certifi"
+ except Exception:
+ mode = "default"
+ return mode
+
+
+def is_certificate_error(exc: BaseException | None) -> bool:
+ """True for a failed certificate check, however urllib, http.client or requests wrapped it."""
+ seen = 0
+ while exc is not None and seen < 6:
+ if isinstance(exc, ssl.SSLCertVerificationError) or "CERTIFICATE_VERIFY_FAILED" in str(exc):
+ return True
+ exc = getattr(exc, "reason", None) if isinstance(getattr(exc, "reason", None), BaseException) else (exc.__cause__ or exc.__context__)
+ seen += 1
+ return False
+
+
+TRY = ("Things to try, in this order: 1) check that the date and time of this PC are right; 2) in your antivirus or security suite, switch off "
+ "'HTTPS scanning' / 'web shield' for Strata, or add Strata and its Python to its exceptions, then try again; 3) if you use a company "
+ "or school network or proxy, ask the person who runs it to trust the download addresses, or try another network (a phone hotspot "
+ "is enough to tell); 4) run Windows Update, which refreshes the certificates the PC trusts. Strata will not skip the check: "
+ "an unchecked download could be a different file.")
+
+
+def explain(host: str | None = None) -> str:
+ """The plain sentence for a certificate failure: no urlopen text, the likely causes, no offer to turn the check off."""
+ where = f"the server {host}" if host else "the download server"
+ return (f"Strata could not confirm that it is really talking to {where}: its security certificate was not accepted. "
+ "Something between this PC and the internet is probably intercepting secure (HTTPS) connections, most often antivirus "
+ "web scanning or a company or school proxy. " + TRY)
+
+
+class CertificateProblem(OSError):
+ """A download stopped because the server's certificate was not accepted. str() is the plain explanation."""
+
+ def __init__(self, host: str | None = None):
+ super().__init__(explain(host))
+ self.host = host
+
+
+def host_of(url: str) -> str | None:
+ try:
+ return url.split("/")[2]
+ except IndexError:
+ return None
+
+
+if __name__ == "__main__": # python -m strata_control.tls: what this process would use
+ print(install(), sys.version.split()[0])
diff --git a/strata_control/transfer.py b/strata_control/transfer.py
index e416b3777..aaeadfd74 100644
--- a/strata_control/transfer.py
+++ b/strata_control/transfer.py
@@ -25,6 +25,10 @@ import urllib.request
from pathlib import Path
from typing import Callable
+from strata_control import tls
+
+tls.install() # #3722: the operating system's certificates, like the browser
+
CHUNK = 1 << 20
SMALL_LIMIT = 8 << 20
ENV_ALLOW_HTTP = "STRATA_UPDATE_ALLOW_HTTP"
@@ -175,9 +179,8 @@ def read_small(location: str, *, limit: int = SMALL_LIMIT, timeout: float = 30)
except (urllib.error.URLError, OSError, TimeoutError) as exc:
reason = getattr(exc, "reason", exc)
hint = ""
- if "CERTIFICATE_VERIFY_FAILED" in str(reason):
- hint = (". This computer did not accept the update server's certificate: check that its date and time are right, "
- "or that a company proxy is not replacing the certificate")
+ if tls.is_certificate_error(exc):
+ raise TransferError(tls.explain(tls.host_of(location))) from None
raise TransferError(f"could not read {location} ({type(exc).__name__}: {reason}){hint}") from None
if len(data) > limit:
raise TransferError(f"{location} is larger than {limit} bytes")
@@ -249,6 +252,8 @@ def _transfer(location, partial: Path, have: int, size: int, progress, cancel, t
resumable=False) from None
raise TransferError(f"the update server answered {exc.code} for {location}") from None
except (urllib.error.URLError, OSError, TimeoutError, ConnectionError, http.client.HTTPException) as exc:
+ if tls.is_certificate_error(exc):
+ raise TransferError(tls.explain(tls.host_of(location)), resumable=True) from None
got = partial.stat().st_size if partial.exists() else 0
reason = getattr(exc, "reason", exc)
raise TransferError(f"the download of {location} was interrupted after {got} of {size} bytes "
diff --git a/tests/terminal/test_tls_trust.py b/tests/terminal/test_tls_trust.py
new file mode 100644
index 000000000..33daf5d72
--- /dev/null
+++ b/tests/terminal/test_tls_trust.py
@@ -0,0 +1,114 @@
+"""#3722: HTTPS downloads check the server against the operating system's certificates (truststore), fall back to certifi, and a
+certificate that still fails gives a plain explanation, never the raw urlopen text and never a way to skip the check."""
+
+import ssl
+import sys
+import types
+import unittest
+import urllib.error
+from pathlib import Path
+from unittest import mock
+
+ROOT = Path(__file__).resolve().parents[2]
+sys.path.insert(0, str(ROOT))
+from strata_control import tls # noqa: E402
+
+RAW = ("<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate "
+ "(_ssl.c:1010)>")
+
+
+def cert_error():
+ inner = ssl.SSLCertVerificationError(1, "[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate")
+ return urllib.error.URLError(inner)
+
+
+class Install(unittest.TestCase):
+ def setUp(self):
+ self.mode = tls.mode
+ self.context = ssl._create_default_https_context
+ tls.mode = None
+ self.addCleanup(self.restore)
+
+ def restore(self):
+ tls.mode = self.mode
+ ssl._create_default_https_context = self.context
+
+ def test_truststore_is_used_when_present(self):
+ fake = types.SimpleNamespace(calls=0)
+ fake.inject_into_ssl = lambda: setattr(fake, "calls", fake.calls + 1)
+ with mock.patch.dict(sys.modules, {"truststore": fake}):
+ self.assertEqual(tls.install(), "truststore")
+ self.assertEqual(tls.install(), "truststore") # again: nothing more happens
+ self.assertEqual(fake.calls, 1)
+
+ def test_certifi_is_the_fallback_when_truststore_is_missing(self):
+ seen = {}
+ fake_certifi = types.SimpleNamespace(where=lambda: "bundle.pem")
+ with mock.patch.dict(sys.modules, {"truststore": None, "certifi": fake_certifi}), \
+ mock.patch.object(ssl, "create_default_context", lambda cafile=None, **k: seen.setdefault("cafile", cafile)):
+ self.assertEqual(tls.install(), "certifi")
+ ssl._create_default_https_context()
+ self.assertEqual(seen["cafile"], "bundle.pem")
+
+ def test_python_default_stays_when_neither_exists(self):
+ with mock.patch.dict(sys.modules, {"truststore": None, "certifi": None}):
+ self.assertEqual(tls.install(), "default")
+ self.assertIs(ssl._create_default_https_context, self.context)
+
+ def test_the_pins_name_truststore_in_requirements_and_every_lock(self):
+ self.assertIn("truststore==", (ROOT / "requirements.txt").read_text())
+ for lock in (ROOT / "packaging" / "locks").glob("runtime-*-cp312.txt"):
+ text = lock.read_text()
+ self.assertRegex(text, r"truststore==\S+ \\r?\n\s+--hash=sha256:[0-9a-f]{64}", lock.name)
+ self.assertIn("certifi==", text) # the fallback stays
+
+
+class Plain(unittest.TestCase):
+ def test_a_failed_certificate_is_recognised_however_it_is_wrapped(self):
+ self.assertTrue(tls.is_certificate_error(cert_error()))
+ self.assertTrue(tls.is_certificate_error(OSError(RAW)))
+ wrapped = RuntimeError("x")
+ wrapped.__cause__ = cert_error()
+ self.assertTrue(tls.is_certificate_error(wrapped))
+ self.assertFalse(tls.is_certificate_error(urllib.error.URLError(ConnectionRefusedError())))
+ self.assertFalse(tls.is_certificate_error(None))
+
+ def test_the_message_is_plain_and_never_offers_to_skip_the_check(self):
+ text = tls.explain("github.com")
+ for word in ("github.com", "antivirus", "proxy", "date and time", "Windows Update"):
+ self.assertIn(word, text)
+ for raw in ("urlopen", "CERTIFICATE_VERIFY_FAILED", "_ssl.c", "issuer"):
+ self.assertNotIn(raw, text)
+ self.assertRegex(text, r"will not skip the check")
+ self.assertNotRegex(text.lower(), r"verify\s*=\s*false|insecure|disable (the )?verification|turn off (the )?(certificate|verification)")
+
+ def test_setup_urlopen_raises_the_plain_problem(self):
+ import setup
+ request = types.SimpleNamespace(full_url="https://github.com/x/y")
+ with mock.patch.object(setup.acquisition, "require", lambda *a, **k: None), \
+ mock.patch.object(setup.urllib.request, "urlopen", side_effect=cert_error()):
+ with self.assertRaises(tls.CertificateProblem) as cm:
+ setup._urlopen(request)
+ self.assertIn("github.com", str(cm.exception))
+ self.assertNotIn("CERTIFICATE_VERIFY_FAILED", str(cm.exception))
+
+ def test_setup_urlopen_leaves_other_errors_alone(self):
+ import setup
+ refused = urllib.error.URLError(ConnectionRefusedError())
+ with mock.patch.object(setup.acquisition, "require", lambda *a, **k: None), \
+ mock.patch.object(setup.urllib.request, "urlopen", side_effect=refused):
+ with self.assertRaises(urllib.error.URLError):
+ setup._urlopen(types.SimpleNamespace(full_url="https://github.com/x"))
+
+ def test_the_update_reader_gives_the_plain_message(self):
+ from strata_control import transfer
+ with mock.patch.object(transfer, "check_url_policy", lambda url: None), \
+ mock.patch.object(transfer._opener, "open", side_effect=cert_error()):
+ with self.assertRaises(transfer.TransferError) as cm:
+ transfer.read_small("https://updates.example.org/feed.json")
+ self.assertIn("antivirus", str(cm.exception))
+ self.assertNotIn("urlopen", str(cm.exception))
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tools/hf_pin_fetch.py b/tools/hf_pin_fetch.py
index afe941dea..5387b44b6 100644
--- a/tools/hf_pin_fetch.py
+++ b/tools/hf_pin_fetch.py
@@ -14,6 +14,11 @@ import sys
import urllib.request
from pathlib import Path
+sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
+from strata_control import tls # noqa: E402
+
+tls.install() # #3722: the operating system's certificates
+
def tree(repo: str, revision: str) -> dict:
"""{path: (size, sha256)} of the repository's LFS files at `revision` (the API pages its answer with Link headers)."""
diff --git a/tools/mtp_fetch.py b/tools/mtp_fetch.py
index 14898aef0..8968dfa50 100644
--- a/tools/mtp_fetch.py
+++ b/tools/mtp_fetch.py
@@ -29,6 +29,11 @@ import time
import urllib.error
import urllib.request
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+from strata_control import tls # noqa: E402
+
+tls.install() # #3722: the operating system's certificates
+
# #214: a fixed commit of the checkpoint (its `sha` from https://huggingface.co/api/models/Qwen/Qwen3.8-Flash-Next
# on 2026-09-30), so every install reads the same tensors; STRATA_MTP_REVISION overrides it (e.g. main). When the
# repository no longer has it, reading stops (resolve_repo) unless STRATA_ALLOW_UNPINNED=1.
diff --git a/tools/test_setup_pins.py b/tools/test_setup_pins.py
index 49fee8129..83d73fb2e 100644
--- a/tools/test_setup_pins.py
+++ b/tools/test_setup_pins.py
@@ -408,6 +408,9 @@ class Requirements(unittest.TestCase):
lines = setup.requirement_lines()
legacy = sorted(setup.PY_PACKAGES) + ["nvidia-cublas==13.0.2.14"]
deps = {"markupsafe", "certifi", "charset-normalizer", "idna", "urllib3", "colorama"}
+ # the packages it has stay as they are; only truststore (#3722: the operating system's certificates) is new, and it is wanted
+ self.assertEqual(self.pip(legacy, lines, installed=deps)[0], ['truststore==0.10.5; python_version >= "3.10"'])
+ deps.add("truststore")
self.assertEqual(self.pip(legacy, lines, installed=deps)[0], [])
missing = [p for p in legacy if p != "psutil"] # an older list without psutil
ran, _ = self.pip(missing, lines, installed=deps)