明霞 (Discord, Windows) behind an HTTPS-scanning box whose root is in the
OS store: every plugin request answered "self signed certificate in
certificate chain" (WorkBuddy AI on Routing), and updating the Qoder
plugin failed with UNABLE_TO_GET_ISSUER_CERT_LOCALLY.
magpie gave Bun only NODE_EXTRA_CA_CERTS, a file of the roots as magpie
read them: on Windows the current user's ROOT view only. Bun's own system
loader (root_certs_windows.cpp, Bun 1.4.2) reads ROOT, CA and
TrustedPeople of the machine, the user, group policy and the enterprise,
server-auth certs only: an intermediate a proxy doesn't send and a root
pushed by policy are there and weren't in magpie's file. bunCommand,
which starts every bun (the plugin host, bun add/update, the dist-branch
install), now also sets NODE_USE_SYSTEM_CA=1. Bun's runtime fetch and
bun add's HTTP client both build their store in us_get_default_ca_store,
which merges the system store when that variable is 1 (checked in
Bun's source at bun-v1.4.2, and by running it). Verification is never
turned off. A NODE_USE_SYSTEM_CA the user set (0 too) is kept; a
NODE_EXTRA_CA_CERTS the user set is kept and Bun takes it beside the
system store. magpie's own file is still given when the user has none,
for an older MAGPIE_BUN without the variable.
Go side unchanged: magpie's own clients (the dist-branch tarball
included) use crypto/x509's platform verifier on Windows and macOS and
SSL_CERT_FILE/SSL_CERT_DIR plus the distribution bundle on Linux; no
RootCAs is overridden anywhere.
Run:
- TestBunTrustsTheSystemsStore (new): a local TLS server signed by a test
root, sending leaf+root, serving a one-package npm registry; real Bun
1.4.2 fetch and bun add through bunCommand. Root in neither store:
both refused. Root in the system store (Linux: SSL_CERT_DIR, the
machine's store untouched): both get through. Root in the user's
NODE_EXTRA_CA_CERTS: both get through.
Linux (wsl-run, magpie-desktop): pass. Old systemca.go: the system-store
case is red (fetch and bun add both fail), as is TestBunReadsTheSystemsStore.
Windows (win-run, xiaomi-gpu) and macOS (mote): pass; the system-store
case is skipped there, since it needs a change to the real trust store.
- TestBunReadsTheSystemsStore (new), TestBunIsGivenTheSystemsRoots: Linux,
Windows, macOS pass.
- go test -tags nogui ./internal/plugin on mote: ok (116s). Windows
TestHost* on xiaomi-gpu: ok.
- go build ./..., GOOS=windows and GOOS=linux go vet ./internal/plugin on
mote; gofmt -l clean.
- On xiaomi-gpu, bun 1.4.2 with NODE_USE_SYSTEM_CA=1:
tls.getCACertificates("default") 183 (121 bundled + 62 system); without
it 121. magpie's own ROOT file there loads whole (35 certs).
Not run: full suite.
Not tried: a root actually installed in the Windows or macOS store (the
real trust stores were left alone), and the reporter's antivirus/proxy.
Bun 1.4.2 on Windows reads NODE_EXTRA_CA_CERTS as ANSI and takes it as
UTF-8: C:\Users\<中文>\.cache\magpie\bun\system-ca-*.pem became
"锟斤拷" and "load failed: No such file or directory". An 8.3 short name
doesn't help (Windows gives 测试 none). Bun opens a relative path from
where it runs, which is under the same user folder, so the path is given
relative to Bun's dir when it isn't ASCII.
Tried on the Windows box with Bun 1.4.2 and a local HTTPS server signed
by a test root, from a cwd under 测试: absolute path -> warn + FAIL
UNABLE_TO_VERIFY_LEAF_SIGNATURE; relative path -> 200. The new test's
Windows cases ran there (windows/amd64 test binary): PASS.