Skip to content

fix(agent): honor custom CA certs for custom_providers HTTPS endpoints - #56393

Closed
HexLab98 wants to merge 2 commits into
NousResearch:mainfrom
HexLab98:fix/custom-provider-ssl-ca-cert
Closed

fix(agent): honor custom CA certs for custom_providers HTTPS endpoints#56393
HexLab98 wants to merge 2 commits into
NousResearch:mainfrom
HexLab98:fix/custom-provider-ssl-ca-cert

Conversation

@HexLab98

@HexLab98 HexLab98 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add resolve_httpx_verify() so the primary OpenAI/httpx client honors HERMES_CA_BUNDLE, SSL_CERT_FILE, and per-provider ssl_ca_cert settings.
  • Add ssl_ca_cert / ssl_verify fields to custom_providers / providers config and wire them into agent client creation.

Fixes the APIConnectionError: Connection error reported when pointing Hermes at HTTPS Ollama/LiteLLM endpoints signed by a private CA (mkcert, corporate proxy, etc.).

Test plan

  • scripts/run_tests.sh tests/agent/test_ssl_verify.py tests/hermes_cli/test_custom_provider_tls.py tests/run_agent/test_create_openai_client_ssl_verify.py
  • Manual: Ollama behind Caddy + mkcert with ssl_ca_cert: /path/to/rootCA.pem in custom_providers

HexLab98 added 2 commits July 1, 2026 19:51
Introduce a shared helper that maps HERMES_CA_BUNDLE, SSL_CERT_FILE, and
per-provider ssl_ca_cert settings to httpx verify contexts.
Wire ssl_ca_cert and ssl_verify through custom_providers config and env
vars into the keepalive httpx client, fixing APIConnectionError against
mkcert/self-signed Ollama proxies behind HTTPS.
@HexLab98
HexLab98 force-pushed the fix/custom-provider-ssl-ca-cert branch from 29499ab to a580514 Compare July 1, 2026 12:52

@tonydwb tonydwb 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.

LGTM — clean implementation of per-provider TLS settings for custom providers. The ssl_verify.py module is well-structured with clear priority ordering, and the test coverage (ssl_verify, custom_provider_tls, keepalive_client) is thorough. Minor note: the bare except: pass in agent_init.py and switch_model catches all exceptions including potential import errors, but this is acceptable for a non-critical init path.

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint area/auth Authentication, OAuth, credential pools P2 Medium — degraded but workaround exists labels Jul 1, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related: this is part of the SSL/custom-CA cluster — it implements feature issue #48440 (per-provider ssl_ca_cert) and overlaps OPEN PRs #48891 (broader stacked-branch version that bundles extra features) and #28271 (ssl_verify-only), plus issue #28260 and merged #14533 (env-var CA across requests callsites). This PR is the cleanest focused implementation of the per-provider CA path with verification kept on by default; flagging the cluster so a maintainer can pick one canonical approach. Not a duplicate — no earlier same-scope open PR it copies.

@tonydwb tonydwb 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.

Code Review Summary

Verdict: LGTM

Adds custom CA certificate support for custom_providers HTTPS endpoints. New agent/ssl_verify.py module resolves httpx verify from config, env vars, and per-provider settings.

Looks Good

  • Clean priority chain: ssl_verify:false > ca_bundle > env vars > True
  • Per-provider ssl_ca_cert and ssl_verify config fields properly normalized
  • Keepalive httpx client correctly receives verify parameter
  • Comprehensive tests: 3 test files covering verify resolution, custom provider TLS, and client creation
  • Exception handling in agent_init is appropriate (best-effort TLS)

Reviewed by Hermes Agent

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Merged via #56681#56681

Your two commits were cherry-picked with authorship preserved (rebase-merge), so they land on main as yours (7e957cbd0, 3a2ba959c). Thanks for the fix!

We extended it on top in a follow-up:

  • Auxiliary-client parity — the salvaged change fixed the main OpenAI client, but auxiliary tasks (compression, vision, web_extract, title generation, session_search) build a separate keepalive client via agent/process_bootstrap.build_keepalive_http_client, which had the identical no-verify pattern. So chat worked against a private-CA endpoint but every auxiliary call still threw APIConnectionError. Now both paths share the same resolve_httpx_verify resolution.
  • switch_model reads custom_providers from live config (not the init-time snapshot) so ssl_ca_cert/ssl_verify edits apply on a mid-session model switch.
  • Dropped the dead client-level verify= where a custom httpx transport owns the SSL context; added CURL_CA_BUNDLE to the env chain and a loud warning when ssl_verify: false disables verification; case-insensitive base_url match.

This closes the SSL/custom-CA cluster (implements #48440 and #28260).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants