Skip to content

fix(cli): restore macOS system CA trust - #113112

Merged
steipete merged 3 commits into
mainfrom
steipete/restore-one-shot-system-ca
Jul 23, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/restore-one-shot-system-ca

Conversation

@steipete

@steipete steipete commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #113108
Follow-up to #110341 and #112868

What Problem This Solves

Fixes an issue where macOS one-shot commands avoided a Node Keychain shutdown hang by disabling inherited system CA trust. The later bundled-CA mitigation restored public WebPKI, but private enterprise and Keychain-only roots still disappeared despite NODE_USE_SYSTEM_CA=1 or an explicit --use-system-ca option.

Why This Change Was Made

OpenClaw now preserves Node's inherited and explicit CA policy. The respawn layer no longer changes NODE_USE_SYSTEM_CA or inserts bundled/OpenSSL CA flags.

The shutdown fix moves to the outer CLI lifecycle boundary. After a command has returned, failure diagnostics have been emitted, shared harness/memory/proxy teardown has completed, and stdout/stderr have drained, macOS processes actually using system CA exit explicitly. Long-lived commands are not preclassified or interrupted: their run promise must settle before finalization executes.

Command-specific exit codes remain authoritative. Failure reporting overwrites a previously queued successful help exit, integer-string process.exitCode values are normalized, and both --use-system-ca and Node's valid --use_system_ca spelling are recognized.

User Impact

macOS one-shot commands retain system and login Keychain trust—including private enterprise roots—while still exiting promptly. Public roots, NODE_EXTRA_CA_CERTS, explicit bundled/OpenSSL choices, interactive commands, watchers, foreground Gateway runs, and embedded custom runtimes keep their existing behavior.

Evidence

  • Real macOS respawn proof: NODE_USE_SYSTEM_CA remained 1; system certificates were present; the default CA set included system roots; config validate --json emitted complete JSON and exited with its expected nonzero status in 1.604 seconds.
  • Focused suite: 253/253 tests passed across respawn policy, outer finalization, failure status/drain ordering, long-lived completion timing, help, hooks, and spawned Gateway-backed CLI exit.
  • Blacksmith Testbox / Actions run 30028887363: check:changed passed formatting, core and test typechecks, lint, database/storage guards, and import-cycle checks.
  • pnpm deadcode:full passes after keeping low-level drain/system-CA helpers private and testing through the production outer finalizer.
  • Final Codex autoreview (gpt-5.6-sol, xhigh, P0-P2) reported no accepted or actionable findings after failure-ordering, teardown, option-spelling, Vitest-marker, and exit-code findings were applied.
  • git diff --check and targeted formatting are clean.

AI-assisted: yes. The process lifecycle and Node CA contracts were repeatedly reviewed and behavior-tested before submission.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: M maintainer Maintainer-authored PR labels Jul 23, 2026
@steipete
steipete marked this pull request as ready for review July 23, 2026 17:28
@steipete

steipete commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Land-ready proof for head 38d2acdb9cb4880445eac6679fc4ae1c5ab1bee2:

  • Real macOS respawn retained NODE_USE_SYSTEM_CA=1; system Keychain certificates were present and included in the default CA set.
  • config validate --json emitted complete JSON, preserved its expected exit status 1, produced no stderr truncation, and finished in 1.604 seconds.
  • Focused suite: 253/253 tests passed across CA respawn policy, outer finalization, command/teardown failures, status preservation, stream drains, long-lived timing, help/hooks, and Gateway-backed process exit.
  • Blacksmith Testbox / Actions run 30028887363: check:changed passed formatting, core/test typechecks, lint, database/storage guards, and import-cycle checks.
  • pnpm deadcode:full passed after the low-level drain/system-CA helpers were kept private and tests were routed through the production outer finalizer.
  • Exact-head hosted CI passed.
  • Final Codex autoreview (gpt-5.6-sol, xhigh, P0-P2): all verified findings were applied. One final claim was rejected as stale because the failure path unconditionally replaces a queued success code and the exact regression test passes.

Known proof gaps: none for the CLI trust/exit contract. Extended stable 2026.6.33 never contained the regression; the active release/2026.7.2 branch should receive this fix after main lands.

@steipete
steipete merged commit 4bd01bd into main Jul 23, 2026
134 of 136 checks passed
@steipete
steipete deleted the steipete/restore-one-shot-system-ca branch July 23, 2026 18:28
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

cli CLI command changes maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: macOS one-shot CLI drops system Keychain CA trust

1 participant