c9e8422fa8c2b8eb96dfb7ff0c91c2caef1306bd
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
331f201faf |
plugin: a cross-signed root copy in Windows' ROOT store no longer shadows Bun's own root (youyo.p_10001)
youyo.p_10001 (Discord #feedback, magpie 0.1.2993 windows/amd64, Bun 1.4.4, Clash Verge on 127.0.0.1:7897): every MiniMax plugin request to agent.minimaxi.com failed "unable to get issuer certificate", while the same chain verified outside the plugin host. Cause: magpie hands Bun the user's Windows ROOT store as NODE_EXTRA_CA_CERTS. Bun (BoringSSL) builds the chain up through the first trusted certificate with the subject it wants, the extra file's ahead of its own bundle, and stops when that one's issuer is missing. A ROOT store holding USERTrust RSA's copy cross-signed by AAA Certificate Services (agent.minimaxi.com's chain goes leaf, WoTrus DV, USERTrust RSA) gave Bun that copy ahead of the self-signed root it ships, and AAA is in neither. Node, curl and Schannel go on to the self-signed one, so outside magpie it worked. Fix: rootsFirst writes the self-signed roots first and keeps another certificate only when its issuer is in the file too. Bun never ends a chain on one that isn't self-signed (no partial chains), so one left out could only stand in front of a root. NODE_USE_SYSTEM_CA=1 stays: the system store Bun reads itself comes after its bundle and shadows nothing (tried, below). Also, for the next report like it: - the host logs its network settings when it starts, and when the proxy (or the gateway's address) moves, old to new: the proxy without user and password (netproxy.Redact), NO_PROXY, NODE_EXTRA_CA_CERTS, NODE_USE_SYSTEM_CA, SSL_CERT_FILE/DIR (netLine); - a fetch Bun refuses for the certificate keeps Bun's words and its code and cause, and adds "(UNABLE_TO_GET_ISSUER_CERT: the plugin host's TLS didn't verify agent.minimaxi.com's certificate chain against the roots it trusts)", so it doesn't read as the vendor's fault (throwTLS in host.js). The plugin side, a China-site account call that can't reach agent.minimaxi.com going once to agent.minimax.cn, is opencode-minimax-auth 0.2.3 (magpie-community/plugins#757). Run: - Reproduced on xiaomi-gpu (Windows 11, Bun 1.4.2) with the real host and the real ROOT store: the real cross-signed USERTrust RSA (valid to 2028) imported into LocalMachine\Root, then a scratch test through bunCommand (NODE_USE_SYSTEM_CA=1 included) fetching https://agent.minimaxi.com/: the file as before -> UNABLE_TO_GET_ISSUER_CERT, rootsFirst's -> 200. Certificate removed after (checked); without it both 200. Also as NODE_EXTRA_CA_CERTS alone: cross copy -> UNABLE_TO_GET_ISSUER_CERT; self-signed then cross -> 200; cross then self-signed -> UNABLE_TO_GET_ISSUER_CERT; cross with AAA either order -> 200. The cross copy in CurrentUser\CA with NODE_USE_SYSTEM_CA=1 -> 200 (no shadowing from the system store). - New tests: TestRootsFirstPutsTheSelfSignedCopyAhead, TestBunGetsPastACrossSignedRootCopy (a synthetic cross chain through Bun), TestPluginTLSRefusalSaysWhose (through the fake plugin's fetch; Bun's message there is the reporter's "unable to get issuer certificate"), TestNetLineSaysNoSecret. Green on mote (macOS, Bun 1.4.2) and on xiaomi-gpu via win-run, with the systemca tests beside them. - Broken by hand on mote: rootsFile without rootsFirst -> TestBunGetsPastACrossSignedRootCopy/the_cross-signed_copy_first red; throwTLS rethrowing as is -> TestPluginTLSRefusalSaysWhose red ("err = unable to get issuer certificate"). - mote, at this tree: gofmt -l clean; go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet of internal/plugin ok; go test ./internal/plugin ok (111.7s). xiaomi-gpu: go test -run 'Proxy|CA|TLS|Roots|NetLine|LAN|Network' ./internal/plugin ok. Not tried: the reporter's own machine and store (what put the cross copy in their ROOT store is a guess from the error; the host's new log line will show NODE_EXTRA_CA_CERTS, and the file is in the cache's bun folder); Bun 1.4.4 (the reporter's; 1.4.2 here); macOS keychain copies (rootsFirst applies to systemRoots there too, untried with a real cross copy); Linux takes the distribution's bundle as it is, unchanged. |
||
|
|
955cb43812 |
plugin: Bun reads the system's trust store itself (NODE_USE_SYSTEM_CA)
明霞 (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.
|
||
|
|
6d830a3c95 |
plugin: Bun on Windows is given an ASCII way to the system's roots, so a user folder with a Chinese name no longer fails bun add with UNABLE_TO_VERIFY_LEAF_SIGNATURE (#1232)
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. |
||
|
|
564033d044 | plugin: Bun is given the roots the system trusts — installing @magpie-community/opencode-kiro-auth failed with "error: UNABLE_TO_VERIFY_LEAF_SIGNATURE downloading package manifest" (chenyyi001 on X): Bun checks TLS against the roots it ships, not the system's, so behind a box that re-signs HTTPS with a root the user installed (a company proxy, a VPN, Surge's or Proxyman's MITM) magpie gets through and bun add, and a plugin's own requests, don't. bunCommand, which starts every bun (installs and the host), now sets NODE_EXTRA_CA_CERTS to the system's roots unless the user set it: on macOS the certificates in the System and login keychains the user or an admin marked as trusted (security trust-settings-export; one denied, or only kept in a keychain, stays out; Apple's own aren't added), written once a run beside Bun's cache; on Linux the distribution's CA bundle (SSL_CERT_FILE first); on Windows the ROOT store. NODE_USE_SYSTEM_CA does nothing for bun 1.4.2's installs. Reproduced with a local registry behind a re-signing proxy: bun add through bunCommand fails with the reporter's error on the old code and installs opencode-kiro-auth@0.1.7 with the proxy's root trusted; TestBunIsGivenTheSystemsRoots fails on the old code and passes, TestTrustedIn and TestSystemRootsAreTheTrustedOnes cover the trust settings. Not tried: a real keychain-trusted root (changing trust settings is left to the user), and the Windows store on a Windows machine (the test box was unreachable; it builds). go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui of internal/plugin and internal/proc under a temp HOME pass. |