Skip to content

Commit

Permalink
java: fix paths for Windows and JRE (#54)
Browse files Browse the repository at this point in the history
Fixes #53
  • Loading branch information
adamdecaf authored and FiloSottile committed Aug 19, 2018
1 parent 70f19a1 commit 4f82e1c
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions truststore_java.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"hash"
"os"
"os/exec"
"path"
"path/filepath"
"runtime"
"strings"
)

Expand All @@ -29,17 +29,31 @@ var (
)

func init() {
if runtime.GOOS == "windows" {
keytoolPath = filepath.Join("bin", "keytool.exe")
} else {
keytoolPath = filepath.Join("bin", "keytool")
}

if v := os.Getenv("JAVA_HOME"); v != "" {
hasJava = true
javaHome = v

_, err := os.Stat(path.Join(v, "bin/keytool"))
_, err := os.Stat(filepath.Join(v, keytoolPath))
if err == nil {
hasKeytool = true
keytoolPath = path.Join(v, "bin/keytool")
keytoolPath = filepath.Join(v, keytoolPath)
}

cacertsPath = path.Join(v, "jre/lib/security/cacerts")
_, err = os.Stat(filepath.Join(v, "lib", "security", "cacerts"))
if err == nil {
cacertsPath = filepath.Join(v, "lib", "security", "cacerts")
}

_, err = os.Stat(filepath.Join(v, "jre", "lib", "security", "cacerts"))
if err == nil {
cacertsPath = filepath.Join(v, "jre", "lib", "security", "cacerts")
}
}
}

Expand Down

0 comments on commit 4f82e1c

Please sign in to comment.