Fix NODE_EXTRA_CA_CERTS missing from LaunchAgent environment on macOS#22929
Closed
Clawborn wants to merge 1 commit intoopenclaw:mainfrom
Closed
Fix NODE_EXTRA_CA_CERTS missing from LaunchAgent environment on macOS#22929Clawborn wants to merge 1 commit intoopenclaw:mainfrom
Clawborn wants to merge 1 commit intoopenclaw:mainfrom
Conversation
launchd services do not inherit the shell environment, so Node's undici/fetch cannot locate the macOS system CA bundle (/etc/ssl/cert.pem). This causes TLS verification failures for all HTTPS requests (e.g. Telegram, webhooks) when the gateway runs as a LaunchAgent, while the same gateway works fine in a terminal. Add NODE_EXTRA_CA_CERTS defaulting to /etc/ssl/cert.pem on macOS in both buildServiceEnvironment and buildNodeServiceEnvironment. User-supplied NODE_EXTRA_CA_CERTS is always respected and takes precedence. Fixes openclaw#22856 Co-authored-by: Clawborn <[email protected]>
Contributor
|
@steipete This fix is needed — the missing The PR is approved and the approach is solid (default to |
Contributor
Contributor
|
Thanks for the PR. Superseded by #27915. |
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.
Problem
When OpenClaw runs as a macOS LaunchAgent (installed via
openclaw gateway install), Node'sundici/fetchcannot locate the system CA bundle becauselaunchddoes not inherit the shell environment. This causes TLS verification failures for all HTTPS connections (Telegram, webhooks, etc.), while the same gateway works fine in a foreground terminal session.Root cause:
buildServiceEnvironmentandbuildNodeServiceEnvironmentinservice-env.tsdid not includeNODE_EXTRA_CA_CERTSin the generated plist environment.Fixes #22856.
Fix
Set
NODE_EXTRA_CA_CERTSto/etc/ssl/cert.pem(the macOS system CA bundle) by default when building the service environment on macOS. A user-suppliedNODE_EXTRA_CA_CERTSin the host environment always takes precedence.The same default is applied to both
buildServiceEnvironment(gateway) andbuildNodeServiceEnvironment(node service) since both run under launchd on macOS.Changes
src/daemon/service-env.ts: addNODE_EXTRA_CA_CERTSto the service environment on macOS, falling back to/etc/ssl/cert.pemwhen not set by the usersrc/daemon/service-env.test.ts: add 4 tests covering the default and user-override cases for both environment buildersGreptile Summary
Fixes TLS verification failures for HTTPS connections when OpenClaw runs as a macOS LaunchAgent by setting
NODE_EXTRA_CA_CERTSto the macOS system CA bundle path (/etc/ssl/cert.pem). The issue occurs because launchd services don't inherit the shell environment, preventing Node's undici/fetch from locating system certificates.NODE_EXTRA_CA_CERTSenvironment variable to bothbuildServiceEnvironmentandbuildNodeServiceEnvironmentfunctions/etc/ssl/cert.pemon macOS (Darwin platform only)NODE_EXTRA_CA_CERTSvalues as overridesConfidence Score: 5/5
Last reviewed commit: 35c5a8e