From e5f9c16f8c95dfc6327b5e988d03a6dcbfbe0e9f Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Sun, 12 Aug 2018 21:44:02 -0400 Subject: [PATCH] Offer a less confusing warning about Firefox on Windows --- main.go | 6 ++++-- truststore_nss.go | 1 + truststore_windows.go | 3 +-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index b09c82f..78e059a 100644 --- a/main.go +++ b/main.go @@ -101,7 +101,7 @@ func (m *mkcert) Run(args []string) { warning = true log.Println("Warning: the local CA is not installed in the system trust store! âš ī¸") } - if hasNSS && !m.checkNSS() { + if hasNSS && CertutilInstallHelp != "" && !m.checkNSS() { warning = true log.Printf("Warning: the local CA is not installed in the %s trust store! âš ī¸", NSSBrowsers) } @@ -176,6 +176,8 @@ func (m *mkcert) install() { if 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) @@ -200,7 +202,7 @@ func (m *mkcert) uninstall() { if hasNSS { if hasCertutil { m.uninstallNSS() - } else { + } else if CertutilInstallHelp != "" { log.Print("") log.Printf(`Warning: "certutil" is not available, so the CA can't be automatically uninstalled from %s (if it was ever installed)! âš ī¸`, NSSBrowsers) log.Printf(`You can install "certutil" with "%s" and re-run "mkcert -uninstall" 👈`, CertutilInstallHelp) diff --git a/truststore_nss.go b/truststore_nss.go index edf925c..8d97b50 100644 --- a/truststore_nss.go +++ b/truststore_nss.go @@ -20,6 +20,7 @@ func init() { for _, path := range []string{ "/usr/bin/firefox", nssDB, "/Applications/Firefox.app", "/Applications/Firefox Developer Edition.app", + "C:\\Program Files\\Mozilla Firefox", } { _, err := os.Stat(path) hasNSS = hasNSS || err == nil diff --git a/truststore_windows.go b/truststore_windows.go index 12a2777..7a3e396 100644 --- a/truststore_windows.go +++ b/truststore_windows.go @@ -13,9 +13,8 @@ import ( ) var ( - FirefoxPath = "C:\\Program Files\\Mozilla Firefox" FirefoxProfile = os.Getenv("USERPROFILE") + "\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles" - CertutilInstallHelp = "" + CertutilInstallHelp = "" // certutil unsupported on Windows NSSBrowsers = "Firefox" )