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.
24 lines
995 B
Go
24 lines
995 B
Go
package plugin
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// The line a host's start and a moved proxy log says the proxy without
|
|
// its password, NO_PROXY, and how Bun is told which roots to trust.
|
|
func TestNetLineSaysNoSecret(t *testing.T) {
|
|
got := netLine([]string{"PATH=/bin", "HTTPS_PROXY=http://me:s3cret@127.0.0.1:7897", "http_proxy=http://127.0.0.1:7897",
|
|
"NO_PROXY=localhost,*.cn", "NODE_USE_SYSTEM_CA=1", "NODE_EXTRA_CA_CERTS=ca.pem", "SSL_CERT_DIR="})
|
|
want := "HTTPS_PROXY=http://127.0.0.1:7897 HTTP_PROXY=http://127.0.0.1:7897 NO_PROXY=localhost,*.cn NODE_EXTRA_CA_CERTS=ca.pem NODE_USE_SYSTEM_CA=1"
|
|
if got != want {
|
|
t.Errorf("netLine = %q\nwant %q", got, want)
|
|
}
|
|
if strings.Contains(got, "s3cret") || strings.Contains(got, "me:") {
|
|
t.Errorf("netLine says the proxy's user or password: %q", got)
|
|
}
|
|
if got := netLine(strings.Split(hostProxy([]string{"NO_PROXY=localhost"}), "\x00")); got != "no proxy NO_PROXY=localhost" {
|
|
t.Errorf("netLine with no proxy = %q", got)
|
|
}
|
|
}
|