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