Skip to content

[FEATURE] Verify TLS using the system trust store by default (breaks in enterprise/proxy environments) #2004

Closed

Description

@fangkangmi

Is your feature request related to a problem? Please describe.

apm fails TLS verification against internal Git hosts that use a corporate CA or a TLS-inspecting proxy, even when git and curl to the same host succeed. This makes the first-run experience in enterprise environments confusing and requires per-shell env-var setup.

What the user sees:

apm marketplace add https://<internal-ghe-host>/Org/repo.git --name foo

[x] Failed to register marketplace: Failed to fetch marketplace 'foo':
HTTPSConnectionPool(host='<internal-ghe-host>', port=443): Max retries exceeded with
url: /api/v3/repos/Org/repo/contents/marketplace.json?ref=main
(Caused by SSLError(SSLCertVerificationError(1,
'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed:
unable to get local issuer certificate (_ssl.c:1010)')))

git clone of the exact same URL succeeds, which is what makes this so confusing.

Why it happens: APM classifies GitHub/GHES/GitLab hosts and fetches marketplace.json (and package metadata) through the REST Contents API using requests, via a plain module-level session:

# src/apm_cli/marketplace/client.py
_HTTP_SESSION = requests.Session()

A default requests.Session() verifies against the bundled certifi CA set (certifi.where()), which does not include internal/corporate root CAs or the certs injected by a TLS-inspecting proxy. The PyInstaller build bundles this set explicitly (build/apm.spec: 'certifi' # CA certificate bundle for SSL verification in frozen binary). Repository operations, by contrast, shell out to git, which reads the OS trust store (e.g. /etc/ssl/certs/ca-certificates.crt) -- so git clone succeeds while the requests-based Contents API call fails against the exact same certificate chain.

Describe the solution you'd like

Use the OS trust store by default via truststore (Python 3.10+; APM already requires >=3.10), e.g. call truststore.inject_into_ssl() once at CLI startup. This automatically picks up corporate CAs on Linux/macOS/Windows with no user configuration, is the modern recommended approach for exactly this problem, and makes git and apm behave consistently against the same host.

Acceptance criteria:

  • A fresh install of APM, in an environment where only the OS trust store contains the corporate CA, can apm marketplace add / apm install from an internal HTTPS Git host without setting any env vars.
  • git-based and requests-based operations use a consistent trust source.
  • Behaviour documented for air-gapped / custom-CA setups (extend the existing troubleshooting/ssl-issues page).

Please do not offer a "disable verification" flag as the primary remedy -- trusting the OS store is the secure fix.

Describe alternatives you've considered

  • REQUESTS_CA_BUNDLE env var (current workaround). This already works and is documented, and APM already prints a hint pointing at it on TLS failure. But it must be re-set per shell / per container and is easy to miss:

    export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt

    Note a sharp edge worth fixing regardless: SSL_CERT_FILE alone does not repair the APM requests path. requests pins certifi.where() and only consults REQUESTS_CA_BUNDLE / CURL_CA_BUNDLE -- it ignores SSL_CERT_FILE. So the fix documented for the older [BUG] SSL certificate issues related to to apm's bundled OpenSSL #428 (setting only SSL_CERT_FILE) does not help the marketplace / install code path; users additionally need REQUESTS_CA_BUNDLE. This split between "what the OS trusts", "what git uses", and "what requests uses" is exactly the confusion truststore removes.

  • A --ca-bundle flag / apm config set ca-bundle <path>. Lets users pin a custom CA file without relying on env vars. Useful as a secondary option, but still not zero-config.

  • Disabling verification. Rejected -- insecure, and not an acceptable default or primary remedy.

Additional context

Related to #428, but distinct: #428 was about APM's bundled OpenSSL pointing at a non-existent python.org cert path. This issue is about internal/corporate root CAs not being present in the bundled certifi set at all, which is the common enterprise failure mode.

Environment where this was observed:

  • APM CLI 0.23.1
  • Bundled Python (PyInstaller, --onedir)
  • Linux (dev container, Ubuntu 24.04), behind a corporate CA / TLS-inspecting proxy
  • git clone of the same URL succeeds; apm marketplace add / apm install fail

Activity

  1. github-actions commented on Jul 3, 2026

    @github-actions

    Triage Panel Verdict -- Issue #2004

    Title: [FEATURE] Verify TLS using the system trust store by default (breaks in enterprise/proxy environments)

    Triage Decision: ACCEPT (enterprise blocker, high priority, bounded fix)


    Panel Review

    DevX UX Expert

    This is a first-run experience blocker in enterprise environments. When git clone succeeds against an internal HTTPS host but apm install / apm marketplace add fail with SSLCertVerificationError, the user has no obvious path forward. The error message does not explain the certifi vs. OS trust store split, and the current documented workaround (REQUESTS_CA_BUNDLE) requires per-shell setup that does not persist.

    The split the author describes -- git reads the OS trust store, requests reads the bundled certifi set -- is the root of the confusion. Making these consistent is the correct fix, not documenting yet another env-var workaround.

    Supply Chain Security Expert

    Using the OS trust store via truststore is more secure than the current certifi approach, not less. The OS trust store is explicitly managed by the enterprise IT/security team; deferring to it means apm honors the organization's declared PKI rather than overriding it with a snapshot CA bundle that may be months out of date. The truststore library is actively maintained, is the recommended approach for exactly this scenario in modern Python tooling, and requires no user configuration once injected at startup. The author's explicit rejection of a --no-verify flag reflects correct security posture and should be honored.

    APM CEO (Arbiter)

    Enterprise viability requires TLS consistency between git-based and requests-based operations. A tool that silently fails TLS where git succeeds will not be adopted in corporate environments. The truststore fix is:

    • Bounded: one truststore.inject_into_ssl() call at CLI entry, one dependency addition, one PyInstaller spec update.
    • Zero user configuration in the common case.
    • Python 3.10+ compatible (APM already requires 3.10+).
    • Actively maintained and already used in major Python tooling.

    Accept for next minor release. The author also identifies a sharp edge worth fixing alongside: SSL_CERT_FILE alone does not repair the requests path (only REQUESTS_CA_BUNDLE / CURL_CA_BUNDLE do). The troubleshooting docs should clarify this split.


    Decision

    Dimension Value
    Decision ACCEPT
    Type feature
    Area enterprise, cli
    Theme security, portability
    Priority high
    Suggested milestone next minor (maintainer to confirm)

    Suggested next action:

    1. Add truststore as a dependency (pinned, with lower bound).
    2. Call truststore.inject_into_ssl() at CLI entry point, before any network call.
    3. Extend build/apm.spec to include truststore in the PyInstaller bundle.
    4. Update docs/troubleshooting/ssl-issues/ to document: (a) OS trust store is now the default source; (b) REQUESTS_CA_BUNDLE remains available for edge cases; (c) SSL_CERT_FILE alone does NOT fix the requests path -- users need REQUESTS_CA_BUNDLE for that.
    5. Add an integration test or CI fixture covering TLS verification behavior with a custom CA.

    Triage status: agentic proposal pending human ratification.
    Silence is approval. Maintainers can:

    • Override any label or milestone above by editing it directly --
      human edits are authoritative and will not be reverted on
      subsequent runs.
    • Re-trigger triage by applying the status/needs-triage label, or
      by removing status/triaged to enroll the issue in the next
      daily sweep.

    Posted by the Triage Panel workflow. See .apm/skills/apm-triage-panel for the panel skill.

    Generated by Triage Panel · 91.2 AIC · ⌖ 13.1 AIC · ⊞ 9.2K · ◷

  2. added
    area/cli
    area/enterprise
    priority/high
    status/accepted
    status/triaged
    type/feature
    on Jul 3, 2026
  3. moved this from Todo to In Progress in APM Roadmapon Jul 3, 2026
  4. added a commit that references this issue on Jul 3, 2026
    98a9755
  5. added a commit that references this issue on Jul 12, 2026
    142e68a
  6. moved this from In Progress to Done in APM Roadmapon Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/cliarea/enterprisepriority/highstatus/acceptedstatus/triagedtype/feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions