From fcebdc9845560b3945005932dfc0651ac06d6b98 Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Sat, 25 Aug 2018 15:52:43 -0600 Subject: [PATCH] nss: use certutil from $PATH if found on macOS (#71) Fixes #70 Thanks to @hostep for testing and fixing the patch. --- truststore_nss.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/truststore_nss.go b/truststore_nss.go index 8d97b50..1987ec8 100644 --- a/truststore_nss.go +++ b/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":