fix(agent): honor custom CA certs for custom_providers HTTPS endpoints (main + aux) - #566
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pointing Hermes at an HTTPS
custom_providersendpoint signed by a private CA (mkcert, corporate proxy, self-signed LiteLLM/Ollama) now works instead of failing withAPIConnectionError: Connection error.Root cause: the agent's httpx client uses a custom
HTTPTransport, which disables httpx'strust_envSSL auto-read — so neither per-provider config norSSL_CERT_FILE/HERMES_CA_BUNDLEreached the client verifying against certifi only.Salvage of NousResearch#56393 by @HexLab98, plus a follow-up extending the fix to the auxiliary-client path and hardening TLS resolution.
Changes
agent/ssl_verify.py(new):resolve_httpx_verify()— priorityssl_verify:false> explicitca_bundle>HERMES_CA_BUNDLE/SSL_CERT_FILE/REQUESTS_CA_BUNDLE/CURL_CA_BUNDLEenv >True. Emits a loudlogger.warning(naming the endpoint) wheneverssl_verify:falsedisables verification.hermes_cli/config.py:ssl_ca_cert/ssl_verifyfields oncustom_providers(normalized, validated, mapped to provider config);get_custom_provider_tls_settings()(case-insensitive exact base_url match — no prefix bypass) +apply_custom_provider_tls_to_client_kwargs().AIAgent._build_keepalive_http_client+create_openai_client+switch_modelforward the resolvedverify.switch_modelreadscustom_providersfrom live config (not the init-time snapshot) so TLS edits apply on mid-session switch, matching the Bug: /model switch to named custom provider ignores custom_providers model context_length NousResearch/hermes-agent#15779 context-length reload.agent/process_bootstrap.build_keepalive_http_clientaccepts/forwardsverify;agent/auxiliary_client._resolve_aux_verify()mirrors the main-client resolution (read-only config fast path) so compression/vision/web_extract/title-gen/session_search honor the same CA. Without this, chat worked but every auxiliary call to the same endpoint still threwAPIConnectionError.verify=where a custom transport is used (httpx ignores it there); demoted best-effortexcept: passtologger.debug.New config lives in
config.yamlundercustom_providers(not.env);HERMES_CA_BUNDLEis a pre-existing convention.Validation
ssl_ca_cert) — main chatAPIConnectionErrorAPIConnectionErrorssl_verify: false(local dev)/modelswitch after editingssl_ca_certverify=True(unchanged, no bypass)HERMES_HOME+ realconfig.yaml: config →_resolve_aux_verify→ auxhttp_clientcarries the customSSLContext;ssl_verify:falsereturnsFalseand warns; non-matching endpoints stay onTrue.Credit
Salvaged from NousResearch#56393 by @HexLab98 (authorship preserved via rebase). Closes the SSL/custom-CA cluster: implements NousResearch#48440 and NousResearch#28260.
Mirror-of: NousResearch#56681
NousResearch#56681