Skip to content

Commit 8bd10b7

Browse files
committed
feat: loadSystemRoots use ExitCode to test cmd success
1 parent 3be4db6 commit 8bd10b7

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

security.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -467,11 +467,11 @@ func loadSystemRoots() (*x509.CertPool, error) {
467467
if needSync {
468468
cmd := exec.Command("certutil", "-syncWithWU", dir)
469469
hideWindow(cmd)
470-
out, err := cmd.Output()
470+
err := cmd.Run()
471471
if err != nil {
472472
return roots, err
473473
}
474-
if !strings.Contains(string(out), "command completed successfully") {
474+
if cmd.ProcessState.ExitCode() != 0 {
475475
return roots, err
476476
}
477477
}

security_test.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"fmt"
1010
"path/filepath"
1111
"reflect"
12-
"runtime"
1312
"testing"
1413
"time"
1514
)
@@ -199,11 +198,10 @@ func TestParseSecurityDirectory(t *testing.T) {
199198
if expected.SignatureValid != cert.SignatureValid {
200199
t.Fatalf("signature verification %d failed, cert %v, want %v", i, cert.SignatureValid, expected.SignatureValid)
201200
}
202-
if runtime.GOOS == "linux" {
203-
if expected.Verified != cert.Verified {
204-
t.Fatalf("certificate verification %d failed, cert %v, want %v", i, cert.Verified, expected.Verified)
205-
}
201+
if expected.Verified != cert.Verified {
202+
t.Fatalf("certificate verification %d failed, cert %v, want %v", i, cert.Verified, expected.Verified)
206203
}
204+
207205
}
208206
})
209207
}

0 commit comments

Comments
 (0)