6 Commits

Author SHA1 Message Date
Filippo Valsorda
b0f7a80e95 Fix getCAROOT switch statement 2018-07-06 20:09:58 -04:00
Lucas Garron
dbad5f86ec Use $XDG_DATA_HOME on macOS if it is set (#40) 2018-07-06 20:02:49 -04:00
Filippo Valsorda
779fa98126 Update README.md 2018-07-04 13:08:32 -04:00
Filippo Valsorda
c4437d46bd Delete local Homebrew Formula now that it's in homebrew-core
See #32
2018-07-04 13:03:43 -04:00
ansemjo
5a2f42dee6 truststore: check if profile is a directory before joining cert*.db (#33) 2018-07-04 12:59:33 -04:00
commitay
2e954de528 readme: update homebrew install (#32) 2018-07-04 12:49:38 -04:00
4 changed files with 13 additions and 29 deletions

View File

@@ -1,18 +0,0 @@
class Mkcert < Formula
desc "Simple tool to make locally-trusted development certificates"
homepage "https://github.com/FiloSottile/mkcert"
head "https://github.com/FiloSottile/mkcert.git"
depends_on "go" => :build
def install
ENV["GOPATH"] = buildpath
mkcertpath = buildpath/"src/github.com/FiloSottile/mkcert"
mkcertpath.install buildpath.children
cd mkcertpath do
system "go", "build", "-o", bin/"mkcert"
prefix.install_metafiles
end
end
end

View File

@@ -33,7 +33,7 @@ mkcert automatically creates and installs a local CA in the system root store, a
On macOS, use Homebrew. On macOS, use Homebrew.
``` ```
brew install --HEAD https://github.com/FiloSottile/mkcert/raw/master/HomebrewFormula/mkcert.rb brew install mkcert
brew install nss # if you use Firefox brew install nss # if you use Firefox
``` ```
@@ -54,7 +54,7 @@ $(go env GOPATH)/bin/mkcert
Windows will be supported next. (PRs welcome!) Windows will be supported next. (PRs welcome!)
Warning: the `rootCA-key.pem` file that mkcert automatically generates gives complete power to intercept secure requests from your machine. Do not share it. > **Warning**: the `rootCA-key.pem` file that mkcert automatically generates gives complete power to intercept secure requests from your machine. Do not share it.
## Advanced topics ## Advanced topics

11
main.go
View File

@@ -137,25 +137,24 @@ func getCAROOT() string {
} }
var dir string var dir string
switch runtime.GOOS { switch {
case "windows": case runtime.GOOS == "windows":
dir = os.Getenv("LocalAppData") dir = os.Getenv("LocalAppData")
case "darwin": case os.Getenv("XDG_DATA_HOME") != "":
dir = os.Getenv("XDG_DATA_HOME")
case runtime.GOOS == "darwin":
dir = os.Getenv("HOME") dir = os.Getenv("HOME")
if dir == "" { if dir == "" {
return "" return ""
} }
dir = filepath.Join(dir, "Library", "Application Support") dir = filepath.Join(dir, "Library", "Application Support")
default: // Unix default: // Unix
dir = os.Getenv("XDG_DATA_HOME")
if dir == "" {
dir = os.Getenv("HOME") dir = os.Getenv("HOME")
if dir == "" { if dir == "" {
return "" return ""
} }
dir = filepath.Join(dir, ".local", "share") dir = filepath.Join(dir, ".local", "share")
} }
}
return filepath.Join(dir, "mkcert") return filepath.Join(dir, "mkcert")
} }

View File

@@ -97,6 +97,9 @@ func (m *mkcert) forEachNSSProfile(f func(profile string)) (found int) {
return return
} }
for _, profile := range profiles { for _, profile := range profiles {
if stat, err := os.Stat(profile); err != nil || !stat.IsDir() {
continue
}
if _, err := os.Stat(filepath.Join(profile, "cert8.db")); !os.IsNotExist(err) { if _, err := os.Stat(filepath.Join(profile, "cert8.db")); !os.IsNotExist(err) {
f("dbm:" + profile) f("dbm:" + profile)
found++ found++