From ba12bc58995e1136a54ff6679e506cf8aff3638f Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Sun, 12 Aug 2018 20:32:34 -0400 Subject: [PATCH] Avoid printing a success message on error Updates #51 --- main.go | 5 ++--- truststore_nss.go | 11 ++++------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index 1b10b0cb..b09c82f9 100644 --- a/main.go +++ b/main.go @@ -174,10 +174,9 @@ func (m *mkcert) install() { printed = true } if hasNSS && !m.checkNSS() { - if hasCertutil { - m.installNSS() + if hasCertutil && m.installNSS() { log.Printf("The local CA is now installed in the %s trust store (requires browser restart)! 🦊", NSSBrowsers) - } else { + } else if !hasCertutil { log.Printf(`Warning: "certutil" is not available, so the CA can't be automatically installed in %s! ⚠️`, NSSBrowsers) log.Printf(`Install "certutil" with "%s" and re-run "mkcert -install" 👈`, CertutilInstallHelp) } diff --git a/truststore_nss.go b/truststore_nss.go index 75cf1f6b..cf2810f0 100644 --- a/truststore_nss.go +++ b/truststore_nss.go @@ -56,24 +56,21 @@ func (m *mkcert) checkNSS() bool { return success } -func (m *mkcert) installNSS() { +func (m *mkcert) installNSS() bool { if m.forEachNSSProfile(func(profile string) { cmd := exec.Command(certutilPath, "-A", "-d", profile, "-t", "C,,", "-n", m.caUniqueName(), "-i", filepath.Join(m.CAROOT, rootName)) out, err := cmd.CombinedOutput() - if err != nil { - log.Printf("!!! You've hit a known issue. Please report the entire command output at https://github.com/FiloSottile/mkcert/issues/12\nProfile path: %s\nOS: %s/%s\ncertutil: %s\n", profile, runtime.GOOS, runtime.GOARCH, certutilPath) - cmd := exec.Command("ls", "-l", profile[4:]) - cmd.Stdout, cmd.Stderr = os.Stderr, os.Stderr - cmd.Run() - } fatalIfCmdErr(err, "certutil -A", out) }) == 0 { log.Printf("ERROR: no %s security databases found", NSSBrowsers) + return false } if !m.checkNSS() { log.Printf("Installing in %s failed. Please report the issue with details about your environment at https://github.com/FiloSottile/mkcert/issues/new 👎", NSSBrowsers) log.Printf("Note that if you never started %s, you need to do that at least once.", NSSBrowsers) + return false } + return true } func (m *mkcert) uninstallNSS() {