Skip to content

Verify TLS against the OS trust store via truststore - #319

Draft
gerardo-navarro wants to merge 3 commits into
developfrom
bugfixes_truststore
Draft

gerardo-navarro wants to merge 3 commits into
developfrom
bugfixes_truststore

Conversation

@gerardo-navarro

@gerardo-navarro gerardo-navarro commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

In corporate networks a TLS-inspecting proxy re-signs HTTPS traffic with an internal root CA. Windows trusts that CA (distributed via GPO), so downloads work in the browser. aTrain's Python verifies against certifi, which does not know the CA. Every model download then fails with CERTIFICATE_VERIFY_FAILED, both for required models and on the models page.

This PR makes Python verify certificates against the OS trust store with truststore, the same approach pip has used since 24.2.

  • pyproject.toml / uv.lock: add truststore==0.10.4 (pure Python, MIT, no dependencies).
  • aTrain_core/globals.py: call truststore.inject_into_ssl() at import. Every process imports this module, including the spawned workers that run the downloads on Windows.
  • tests/unit/test_globals.py: assert that ssl.SSLContext is replaced.
  • .github/workflows/ci.yml: install truststore in the unit job, which installs its deps by hand.

Notes:

References

Refs #318

Screenshots / Examples

Behind a TLS-inspecting proxy whose CA is only in the system store (Linux sandbox), with REQUESTS_CA_BUNDLE unset:

# before: requests.get("https://github.com")
SSLError ... CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain

# after: import aTrain_core.globals; requests.get("https://github.com")
TLS handshake succeeds

Verification Steps

  • uv run --no-sync pytest tests/unit/test_globals.py: new test fails without the fix, passes with it.
  • ruff check, ruff format --check, bandit clean.
  • Windows 11 VM with mitmproxy as system proxy and its CA in the Windows trust store, REQUESTS_CA_BUNDLE unset:
    • models page → Download tiny → finishes (fails today with SSLCertVerificationError).
    • transcription with a model that needs a download → no SSL error.
  • Flatpak: download still works (the sandbox has its own CA store).
  • macOS: download still works (Keychain).

Corporate proxies that re-sign HTTPS traffic use a CA that Windows trusts
but certifi does not. Every model download then fails with
CERTIFICATE_VERIFY_FAILED, while the same download works in the browser.

Inject truststore in aTrain_core.globals, which every process imports,
including the spawned download workers.

Refs #318
# Conflicts:
#	.github/workflows/ci.yml
#	uv.lock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant