Skip to content

Commit 56528f7

Browse files
DASungtaclaude
andcommitted
fix(tls): macOS 15+ 安装 CA 证书无需管理员权限
移除 -d 和 -k /Library/Keychains/System.keychain 参数, 改为写入用户登录 Keychain,避免 macOS 15+ 的 SecTrustSettingsSetTrustSettings 授权报错。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a7dddb0 commit 56528f7

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

internal/tls/ca.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,13 @@ func NeedsRegeneration(dir string, domain string) bool {
159159
func InstallCA(caCertPath string) error {
160160
switch runtime.GOOS {
161161
case "darwin":
162-
return elevatedExec("security", "add-trusted-cert", "-d", "-r", "trustRoot",
163-
"-k", "/Library/Keychains/System.keychain", caCertPath)
162+
// Install into the user login keychain — no admin privileges required.
163+
// Omitting -d and -k /Library/Keychains/System.keychain avoids the
164+
// SecTrustSettingsSetTrustSettings authorization error on macOS 15+.
165+
cmd := exec.Command("security", "add-trusted-cert", "-r", "trustRoot", caCertPath)
166+
cmd.Stdout = os.Stdout
167+
cmd.Stderr = os.Stderr
168+
return cmd.Run()
164169
case "linux":
165170
dest := "/usr/local/share/ca-certificates/trae-proxy.crt"
166171
if err := elevatedExec("cp", caCertPath, dest); err != nil {
@@ -177,7 +182,10 @@ func InstallCA(caCertPath string) error {
177182
func UninstallCA(caCertPath string) error {
178183
switch runtime.GOOS {
179184
case "darwin":
180-
return elevatedExec("security", "remove-trusted-cert", "-d", caCertPath)
185+
cmd := exec.Command("security", "remove-trusted-cert", caCertPath)
186+
cmd.Stdout = os.Stdout
187+
cmd.Stderr = os.Stderr
188+
return cmd.Run()
181189
case "linux":
182190
elevatedExec("rm", "-f", "/usr/local/share/ca-certificates/trae-proxy.crt")
183191
return elevatedExec("update-ca-certificates", "--fresh")

0 commit comments

Comments
 (0)