Skip to content

Commit

Permalink
Support installing to system trust store for Arch-based distros (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
traviscampbell authored and FiloSottile committed Aug 19, 2018
1 parent 047acfa commit 281c560
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -50,6 +50,8 @@ On Linux, install `certutil`
sudo apt install libnss3-tools
-or-
sudo yum install nss-tools
-or-
sudo pacman -S nss
```
and install using [Linuxbrew](http://linuxbrew.sh/).

Expand Down Expand Up @@ -87,7 +89,7 @@ mkcert supports the following root stores:
* macOS system store
* Windows system store
* Linux variants that provide either
* `update-ca-trust` (Fedora, RHEL, CentOS) or
* `update-ca-trust` (Fedora, RHEL, CentOS, Arch) or
* `update-ca-certificates` (Ubuntu, Debian)
* Firefox (macOS and Linux only)
* Chrome and Chromium
Expand Down
20 changes: 12 additions & 8 deletions truststore_linux.go
Expand Up @@ -24,16 +24,15 @@ var (
)

func init() {
_, err := os.Stat("/etc/pki/ca-trust/source/anchors/")
if err == nil {
if pathExists("/etc/pki/ca-trust/source/anchors/") {
SystemTrustFilename = "/etc/pki/ca-trust/source/anchors/mkcert-rootCA.pem"
SystemTrustCommand = []string{"update-ca-trust", "extract"}
} else {
_, err = os.Stat("/usr/local/share/ca-certificates/")
if err == nil {
SystemTrustFilename = "/usr/local/share/ca-certificates/mkcert-rootCA.crt"
SystemTrustCommand = []string{"update-ca-certificates"}
}
} else if pathExists("/usr/local/share/ca-certificates/") {
SystemTrustFilename = "/usr/local/share/ca-certificates/mkcert-rootCA.crt"
SystemTrustCommand = []string{"update-ca-certificates"}
} else if pathExists("/etc/ca-certificates/trust-source/anchors/") {
SystemTrustFilename = "/etc/ca-certificates/trust-source/anchors/mkcert-rootCA.crt"
SystemTrustCommand = []string{"trust", "extract-compat"}
}
if SystemTrustCommand != nil {
_, err := exec.LookPath(SystemTrustCommand[0])
Expand All @@ -43,6 +42,11 @@ func init() {
}
}

func pathExists(path string) bool {
_, err := os.Stat(path)
return err == nil
}

func (m *mkcert) installPlatform() bool {
if SystemTrustCommand == nil {
log.Printf("Installing to the system store is not yet supported on this Linux 😣 but %s will still work.", NSSBrowsers)
Expand Down

0 comments on commit 281c560

Please sign in to comment.