Skip to content

Commit

Permalink
Avoid printing a success message on error
Browse files Browse the repository at this point in the history
Updates #51
  • Loading branch information
FiloSottile committed Aug 13, 2018
1 parent 62149df commit ba12bc5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
5 changes: 2 additions & 3 deletions main.go
Expand Up @@ -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)
}
Expand Down
11 changes: 4 additions & 7 deletions truststore_nss.go
Expand Up @@ -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() {
Expand Down

0 comments on commit ba12bc5

Please sign in to comment.