Skip to content

Commit

Permalink
truststore_darwin: check the default Homebrew path for certutil
Browse files Browse the repository at this point in the history
"mkcert localhost" went from 2.125s to 0.552s, a 4x speedup.

Fixes #135
  • Loading branch information
FiloSottile committed Aug 16, 2019
1 parent 25b1d39 commit 8ff7350
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions truststore_nss.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,15 @@ func init() {

switch runtime.GOOS {
case "darwin":
if hasCertutil = binaryExists("certutil"); hasCertutil {
switch {
case binaryExists("certutil"):
certutilPath, _ = exec.LookPath("certutil")
} else {
hasCertutil = true
case binaryExists("/usr/local/opt/nss/bin/certutil"):
// Check the default Homebrew path, to save executing Ruby. #135
certutilPath = "/usr/local/opt/nss/bin/certutil"
hasCertutil = true
default:
out, err := exec.Command("brew", "--prefix", "nss").Output()
if err == nil {
certutilPath = filepath.Join(strings.TrimSpace(string(out)), "bin", "certutil")
Expand Down

0 comments on commit 8ff7350

Please sign in to comment.