Skip to content

Commit

Permalink
feat: loadSystemRoots use ExitCode to test cmd success
Browse files Browse the repository at this point in the history
  • Loading branch information
LordNoteworthy committed Oct 30, 2024
1 parent a9e66f5 commit 3248242
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions security.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,11 @@ func loadSystemRoots() (*x509.CertPool, error) {
if needSync {
cmd := exec.Command("certutil", "-syncWithWU", dir)
hideWindow(cmd)
out, err := cmd.Output()
err := cmd.Run()
if err != nil {
return roots, err
}
if !strings.Contains(string(out), "command completed successfully") {
if cmd.ProcessState.ExitCode() != 0 {
return roots, err
}
}
Expand Down
8 changes: 3 additions & 5 deletions security_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"fmt"
"path/filepath"
"reflect"
"runtime"
"testing"
"time"
)
Expand Down Expand Up @@ -199,11 +198,10 @@ func TestParseSecurityDirectory(t *testing.T) {
if expected.SignatureValid != cert.SignatureValid {
t.Fatalf("signature verification %d failed, cert %v, want %v", i, cert.SignatureValid, expected.SignatureValid)
}
if runtime.GOOS == "linux" {
if expected.Verified != cert.Verified {
t.Fatalf("certificate verification %d failed, cert %v, want %v", i, cert.Verified, expected.Verified)
}
if expected.Verified != cert.Verified {
t.Fatalf("certificate verification %d failed, cert %v, want %v", i, cert.Verified, expected.Verified)
}

}
})
}
Expand Down

0 comments on commit 3248242

Please sign in to comment.