Avoid printing a success message on error

Updates #51
This commit is contained in:
Filippo Valsorda
2018-08-12 20:32:34 -04:00
parent 62149df1a0
commit ba12bc5899
2 changed files with 6 additions and 10 deletions

View File

@@ -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)
}

View File

@@ -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() {