Skip to content

fix(build): configure bundled CA for binary HTTPS#19

Closed
117503445 wants to merge 1 commit into
mainfrom
fix-binary-ca-bundle
Closed

fix(build): configure bundled CA for binary HTTPS#19
117503445 wants to merge 1 commit into
mainfrom
fix-binary-ca-bundle

Conversation

@117503445

Copy link
Copy Markdown
Collaborator

Summary

  • configure PyInstaller-built binaries to use the bundled certifi CA bundle by default
  • keep user-provided SSL_CERT_FILE unchanged
  • add unit coverage for frozen-binary CA setup

Root Cause

The v0.1.2 standalone binary includes certifi data, but the frozen runtime does not automatically point Python/OpenSSL at that CA bundle. As a result, the FC TempBucket HTTPS request can fail with CERTIFICATE_VERIFY_FAILED unless users manually set SSL_CERT_FILE.

Validation

  • .venv/bin/ruff check src/ tests/
  • .venv/bin/ruff format --check src/ tests/
  • .venv/bin/mypy src/agentrun_cli
  • .venv/bin/pytest tests/unit/test_certificates.py tests/unit/test_main.py tests/integration/test_main.py
  • .venv/bin/pytest tests/unit tests/integration (591 passed)
  • make build
  • frozen binary real smoke without SSL_CERT_FILE / REQUESTS_CA_BUNDLE: skill create returned CREATING, first poll returned READY, then test skill was deleted

Signed-off-by: 117503445 <t117503445@gmail.com>
Copilot AI review requested due to automatic review settings July 6, 2026 06:41

Copilot AI 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.

Pull request overview

This PR ensures PyInstaller-built (frozen) AgentRun CLI binaries automatically use the bundled certifi CA bundle for HTTPS verification by setting SSL_CERT_FILE during frozen startup, while preserving user overrides.

Changes:

  • Add a configure_default_ca_bundle() helper to set SSL_CERT_FILE when running as a frozen binary.
  • Add a PyInstaller runtime hook to invoke the CA setup early in the frozen process lifecycle.
  • Add unit tests covering frozen/non-frozen behavior and user-provided overrides; add certifi as a direct dependency.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/agentrun_cli/_utils/certificates.py Implements frozen-binary CA bundle environment setup.
src/agentrun_cli/_utils/pyinstaller_certifi_hook.py PyInstaller runtime hook to apply CA setup on startup.
agentrun.spec Registers the runtime hook so frozen binaries run the CA setup.
pyproject.toml Adds certifi to runtime dependencies.
tests/unit/test_certificates.py Adds unit coverage for frozen-binary CA behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +11 to +15
if not getattr(sys, "frozen", False):
return
if os.environ.get("SSL_CERT_FILE"):
return
os.environ["SSL_CERT_FILE"] = certifi.where()
Comment on lines +16 to +31
def test_preserves_user_ssl_cert_file(self, monkeypatch):
monkeypatch.setattr(certificates.sys, "frozen", True, raising=False)
monkeypatch.setenv("SSL_CERT_FILE", "/custom/ca.pem")
monkeypatch.setattr(certificates.certifi, "where", lambda: "/tmp/cacert.pem")

certificates.configure_default_ca_bundle()

assert certificates.os.environ["SSL_CERT_FILE"] == "/custom/ca.pem"

def test_skips_regular_python_runtime(self, monkeypatch):
monkeypatch.delattr(certificates.sys, "frozen", raising=False)
monkeypatch.delenv("SSL_CERT_FILE", raising=False)

certificates.configure_default_ca_bundle()

assert "SSL_CERT_FILE" not in certificates.os.environ
@117503445

Copy link
Copy Markdown
Collaborator Author

Closing in favor of #20, which implements the requested simpler business-code approach: default SSL_CERT_FILE to certifi when the user has not set it.

@117503445 117503445 closed this Jul 6, 2026
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.

2 participants