Jelajahi Sumber

nss: use certutil from $PATH if found on macOS (#71)

Fixes #70

Thanks to @hostep for testing and fixing the patch.
Filippo Valsorda 6 tahun lalu
induk
melakukan
fcebdc9845
1 mengubah file dengan 9 tambahan dan 5 penghapusan
  1. 9 5
      truststore_nss.go

+ 9 - 5
truststore_nss.go

@@ -28,13 +28,17 @@ func init() {
 
 	switch runtime.GOOS {
 	case "darwin":
-		out, err := exec.Command("brew", "--prefix", "nss").Output()
+		var err error
+		certutilPath, err = exec.LookPath("certutil")
 		if err != nil {
-			return
+			var out []byte
+			out, err = exec.Command("brew", "--prefix", "nss").Output()
+			if err != nil {
+				return
+			}
+			certutilPath = filepath.Join(strings.TrimSpace(string(out)), "bin", "certutil")
+			_, err = os.Stat(certutilPath)
 		}
-		certutilPath = filepath.Join(strings.TrimSpace(string(out)), "bin", "certutil")
-
-		_, err = os.Stat(certutilPath)
 		hasCertutil = err == nil
 
 	case "linux":