Skip to content

Commit e96a53e

Browse files
committed
fix(desktop): import CA trust variables from the login shell
1 parent 348f217 commit e96a53e

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

‎apps/desktop/src/shell/DesktopShellEnvironment.test.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,32 @@ describe("DesktopShellEnvironment", () => {
367367
}),
368368
);
369369

370+
it.effect("hydrates missing CA trust variables from the login shell", () =>
371+
Effect.gen(function* () {
372+
const env: NodeJS.ProcessEnv = {
373+
SHELL: "/bin/zsh",
374+
PATH: "/usr/bin",
375+
SSL_CERT_DIR: "/etc/ssl/certs",
376+
};
377+
378+
yield* runShellEnvironment({
379+
env,
380+
platform: "darwin",
381+
handler: () =>
382+
envOutput({
383+
PATH: "/opt/zerobrew/bin:/usr/bin",
384+
SSL_CERT_FILE: "/opt/zerobrew/etc/ca-certificates/cacert.pem",
385+
SSL_CERT_DIR: "/opt/zerobrew/etc/ca-certificates",
386+
NODE_EXTRA_CA_CERTS: "/Users/me/corp-root.pem",
387+
}),
388+
});
389+
390+
assert.equal(env.SSL_CERT_FILE, "/opt/zerobrew/etc/ca-certificates/cacert.pem");
391+
assert.equal(env.SSL_CERT_DIR, "/etc/ssl/certs");
392+
assert.equal(env.NODE_EXTRA_CA_CERTS, "/Users/me/corp-root.pem");
393+
}),
394+
);
395+
370396
it.effect("keeps mise's PATH record with the login shell PATH", () =>
371397
Effect.gen(function* () {
372398
const env: NodeJS.ProcessEnv = {

‎apps/desktop/src/shell/DesktopShellEnvironment.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ const LOGIN_SHELL_ENV_NAMES = [
8686
"XDG_SESSION_DESKTOP",
8787
"XDG_SESSION_TYPE",
8888
"WAYLAND_DISPLAY",
89+
"SSL_CERT_FILE",
90+
"SSL_CERT_DIR",
91+
"NODE_EXTRA_CA_CERTS",
8992
"T3CODE_TELEMETRY_ENABLED",
9093
"__MISE_DIFF",
9194
] as const;
@@ -454,6 +457,12 @@ const installPosixEnvironment = Effect.fn("desktop.shellEnvironment.installPosix
454457
"XDG_DATA_HOME",
455458
"XDG_RUNTIME_DIR",
456459
"WAYLAND_DISPLAY",
460+
// CA trust set in the shell profile. Without it, a Node or OpenSSL build
461+
// that has no bundled roots (a shared-OpenSSL node on PATH) cannot verify
462+
// TLS, so provider updaters and agents fail to reach their registries.
463+
"SSL_CERT_FILE",
464+
"SSL_CERT_DIR",
465+
"NODE_EXTRA_CA_CERTS",
457466
// The telemetry opt-out is documented as a shell variable; GUI launches never see it.
458467
"T3CODE_TELEMETRY_ENABLED",
459468
] as const) {

0 commit comments

Comments
 (0)