From 25b1d39486ff151838f466ee1eda38fddc4297a8 Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Fri, 16 Aug 2019 18:04:46 -0400 Subject: [PATCH] Print a message on -install if the CA is already installed Updates #182 --- main.go | 60 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/main.go b/main.go index 71642a6..6ab2f86 100644 --- a/main.go +++ b/main.go @@ -242,37 +242,43 @@ func getCAROOT() string { } func (m *mkcert) install() { - var printed bool - if storeEnabled("system") && !m.checkPlatform() { - if m.installPlatform() { - log.Print("The local CA is now installed in the system trust store! âšĄī¸") - } - m.ignoreCheckFailure = true // TODO: replace with a check for a successful install - printed = true - } - if storeEnabled("nss") && hasNSS && !m.checkNSS() { - if hasCertutil && m.installNSS() { - log.Printf("The local CA is now installed in the %s trust store (requires browser restart)! đŸĻŠ", NSSBrowsers) - } else if CertutilInstallHelp == "" { - log.Printf(`Note: %s support is not available on your platform. â„šī¸`, NSSBrowsers) - } 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) - } - printed = true - } - if storeEnabled("java") && hasJava && !m.checkJava() { - if hasKeytool { - m.installJava() - log.Println("The local CA is now installed in Java's trust store! â˜•ī¸") + if storeEnabled("system") { + if m.checkPlatform() { + log.Print("The local CA is already installed in the system trust store! 👍") } else { - log.Println(`Warning: "keytool" is not available, so the CA can't be automatically installed in Java's trust store! âš ī¸`) + if m.installPlatform() { + log.Print("The local CA is now installed in the system trust store! âšĄī¸") + } + m.ignoreCheckFailure = true // TODO: replace with a check for a successful install } - printed = true } - if printed { - log.Print("") + if storeEnabled("nss") && hasNSS { + if m.checkNSS() { + log.Printf("The local CA is already installed in the %s trust store! 👍", NSSBrowsers) + } else { + if hasCertutil && m.installNSS() { + log.Printf("The local CA is now installed in the %s trust store (requires browser restart)! đŸĻŠ", NSSBrowsers) + } else if CertutilInstallHelp == "" { + log.Printf(`Note: %s support is not available on your platform. â„šī¸`, NSSBrowsers) + } 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) + } + } } + if storeEnabled("java") && hasJava { + if m.checkJava() { + log.Println("The local CA is already installed in Java's trust store! 👍") + } else { + if hasKeytool { + m.installJava() + log.Println("The local CA is now installed in Java's trust store! â˜•ī¸") + } else { + log.Println(`Warning: "keytool" is not available, so the CA can't be automatically installed in Java's trust store! âš ī¸`) + } + } + } + log.Print("") } func (m *mkcert) uninstall() {