mirror of
https://github.com/FiloSottile/mkcert.git
synced 2025-10-13 16:31:41 +08:00
truststore_linux: autodetect CertutilInstallHelp
This commit is contained in:
@@ -16,15 +16,23 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
FirefoxProfile = os.Getenv("HOME") + "/.mozilla/firefox/*"
|
||||
CertutilInstallHelp = `apt install libnss3-tools" or "yum install nss-tools" or "zypper install mozilla-nss-tools`
|
||||
NSSBrowsers = "Firefox and/or Chrome/Chromium"
|
||||
FirefoxProfile = os.Getenv("HOME") + "/.mozilla/firefox/*"
|
||||
NSSBrowsers = "Firefox and/or Chrome/Chromium"
|
||||
|
||||
SystemTrustFilename string
|
||||
SystemTrustCommand []string
|
||||
CertutilInstallHelp string
|
||||
)
|
||||
|
||||
func init() {
|
||||
switch {
|
||||
case binaryExists("apt"):
|
||||
CertutilInstallHelp = "apt install libnss3-tools"
|
||||
case binaryExists("yum"):
|
||||
CertutilInstallHelp = "yum install nss-tools"
|
||||
case binaryExists("zypper"):
|
||||
CertutilInstallHelp = "zypper install mozilla-nss-tools"
|
||||
}
|
||||
if pathExists("/etc/pki/ca-trust/source/anchors/") {
|
||||
SystemTrustFilename = "/etc/pki/ca-trust/source/anchors/%s.pem"
|
||||
SystemTrustCommand = []string{"update-ca-trust", "extract"}
|
||||
@@ -51,6 +59,11 @@ func pathExists(path string) bool {
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func binaryExists(name string) bool {
|
||||
_, err := exec.LookPath(name)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func (m *mkcert) systemTrustFilename() string {
|
||||
return fmt.Sprintf(SystemTrustFilename, strings.Replace(m.caUniqueName(), " ", "_", -1))
|
||||
}
|
||||
|
Reference in New Issue
Block a user