Skip to content

Commit 9d52dcf

Browse files
committed
fix: stabilize launchd CA env tests (#27915) (thanks @Lukavyi)
1 parent 6b59c87 commit 9d52dcf

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Docs: https://docs.openclaw.ai
6969
- CLI/Daemon status TLS probe: use `wss://` and forward local TLS certificate fingerprint for TLS-enabled gateway daemon probes so `openclaw daemon status` works with `gateway.bind=lan` + `gateway.tls.enabled=true`. (#24234) thanks @liuy.
7070
- Podman/Default bind: change `run-openclaw-podman.sh` default gateway bind from `lan` to `loopback` and document explicit LAN opt-in with Control UI origin configuration. (#27491) thanks @robbyczgw-cla.
7171
- Daemon/macOS launchd: forward proxy env vars into supervised service environments, keep LaunchAgent `KeepAlive=true` semantics, and harden restart sequencing to `print -> bootout -> wait old pid exit -> bootstrap -> kickstart`. (#27276) thanks @frankekn.
72+
- Daemon/macOS TLS certs: default LaunchAgent service env `NODE_EXTRA_CA_CERTS` to `/etc/ssl/cert.pem` (while preserving explicit overrides) so HTTPS clients no longer fail with local-issuer errors under launchd. (#27915) Thanks @Lukavyi.
7273
- Gateway/macOS restart-loop hardening: detect OpenClaw-managed supervisor markers during SIGUSR1 restart handoff, clean stale gateway PIDs before `/restart` launchctl/systemctl triggers, and set LaunchAgent `ThrottleInterval=60` to bound launchd retry storms during lock-release races. Landed from contributor PRs #27655 (@taw0002), #27448 (@Sid-Qin), and #27650 (@kevinWangSheng). (#27605, #27590, #26904, #26736)
7374
- Models/MiniMax auth header defaults: set `authHeader: true` for both onboarding-generated MiniMax API providers and implicit built-in MiniMax (`minimax`, `minimax-portal`) provider templates so first requests no longer fail with MiniMax `401 authentication_error` due to missing `Authorization` header. Landed from contributor PRs #27622 by @riccoyuanft and #27631 by @kevinWangSheng. (#27600, #15303)
7475
- Models/Google Antigravity IDs: normalize bare `gemini-3-pro`, `gemini-3.1-pro`, and `gemini-3-1-pro` model IDs to the default `-low` thinking tier so provider requests no longer fail with 404 when the tier suffix is omitted. (#24145) Thanks @byungsker.

src/daemon/service-env.test.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,18 @@ describe("buildServiceEnvironment", () => {
333333
const env = buildServiceEnvironment({
334334
env: { HOME: "/home/user" },
335335
port: 18789,
336+
platform: "darwin",
336337
});
337-
if (process.platform === "darwin") {
338-
expect(env.NODE_EXTRA_CA_CERTS).toBe("/etc/ssl/cert.pem");
339-
} else {
340-
expect(env.NODE_EXTRA_CA_CERTS).toBeUndefined();
341-
}
338+
expect(env.NODE_EXTRA_CA_CERTS).toBe("/etc/ssl/cert.pem");
339+
});
340+
341+
it("does not default NODE_EXTRA_CA_CERTS on non-macOS", () => {
342+
const env = buildServiceEnvironment({
343+
env: { HOME: "/home/user" },
344+
port: 18789,
345+
platform: "linux",
346+
});
347+
expect(env.NODE_EXTRA_CA_CERTS).toBeUndefined();
342348
});
343349

344350
it("respects user-provided NODE_EXTRA_CA_CERTS over the default", () => {
@@ -388,12 +394,17 @@ describe("buildNodeServiceEnvironment", () => {
388394
it("defaults NODE_EXTRA_CA_CERTS to system cert bundle on macOS for node services", () => {
389395
const env = buildNodeServiceEnvironment({
390396
env: { HOME: "/home/user" },
397+
platform: "darwin",
391398
});
392-
if (process.platform === "darwin") {
393-
expect(env.NODE_EXTRA_CA_CERTS).toBe("/etc/ssl/cert.pem");
394-
} else {
395-
expect(env.NODE_EXTRA_CA_CERTS).toBeUndefined();
396-
}
399+
expect(env.NODE_EXTRA_CA_CERTS).toBe("/etc/ssl/cert.pem");
400+
});
401+
402+
it("does not default NODE_EXTRA_CA_CERTS on non-macOS for node services", () => {
403+
const env = buildNodeServiceEnvironment({
404+
env: { HOME: "/home/user" },
405+
platform: "linux",
406+
});
407+
expect(env.NODE_EXTRA_CA_CERTS).toBeUndefined();
397408
});
398409

399410
it("respects user-provided NODE_EXTRA_CA_CERTS for node services", () => {

src/daemon/service-env.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,13 @@ export function buildServiceEnvironment(params: {
236236
port: number;
237237
token?: string;
238238
launchdLabel?: string;
239+
platform?: NodeJS.Platform;
239240
}): Record<string, string | undefined> {
240241
const { env, port, token, launchdLabel } = params;
242+
const platform = params.platform ?? process.platform;
241243
const profile = env.OPENCLAW_PROFILE;
242244
const resolvedLaunchdLabel =
243-
launchdLabel ||
244-
(process.platform === "darwin" ? resolveGatewayLaunchAgentLabel(profile) : undefined);
245+
launchdLabel || (platform === "darwin" ? resolveGatewayLaunchAgentLabel(profile) : undefined);
245246
const systemdUnit = `${resolveGatewaySystemdServiceName(profile)}.service`;
246247
const stateDir = env.OPENCLAW_STATE_DIR;
247248
const configPath = env.OPENCLAW_CONFIG_PATH;
@@ -252,7 +253,7 @@ export function buildServiceEnvironment(params: {
252253
// cannot locate the system CA bundle. Default to /etc/ssl/cert.pem so TLS verification
253254
// works correctly when running as a LaunchAgent without extra user configuration.
254255
const nodeCaCerts =
255-
env.NODE_EXTRA_CA_CERTS ?? (process.platform === "darwin" ? "/etc/ssl/cert.pem" : undefined);
256+
env.NODE_EXTRA_CA_CERTS ?? (platform === "darwin" ? "/etc/ssl/cert.pem" : undefined);
256257
return {
257258
HOME: env.HOME,
258259
TMPDIR: tmpDir,
@@ -274,8 +275,10 @@ export function buildServiceEnvironment(params: {
274275

275276
export function buildNodeServiceEnvironment(params: {
276277
env: Record<string, string | undefined>;
278+
platform?: NodeJS.Platform;
277279
}): Record<string, string | undefined> {
278280
const { env } = params;
281+
const platform = params.platform ?? process.platform;
279282
const stateDir = env.OPENCLAW_STATE_DIR;
280283
const configPath = env.OPENCLAW_CONFIG_PATH;
281284
const tmpDir = env.TMPDIR?.trim() || os.tmpdir();
@@ -284,7 +287,7 @@ export function buildNodeServiceEnvironment(params: {
284287
// cannot locate the system CA bundle. Default to /etc/ssl/cert.pem so TLS verification
285288
// works correctly when running as a LaunchAgent without extra user configuration.
286289
const nodeCaCerts =
287-
env.NODE_EXTRA_CA_CERTS ?? (process.platform === "darwin" ? "/etc/ssl/cert.pem" : undefined);
290+
env.NODE_EXTRA_CA_CERTS ?? (platform === "darwin" ? "/etc/ssl/cert.pem" : undefined);
288291
return {
289292
HOME: env.HOME,
290293
TMPDIR: tmpDir,

0 commit comments

Comments
 (0)