diff --git a/truststore_java.go b/truststore_java.go index 8ad84bb..cf782d6 100644 --- a/truststore_java.go +++ b/truststore_java.go @@ -19,8 +19,9 @@ import ( ) var ( - hasJava bool - hasKeytool bool + hasJava bool + hasKeytool bool + hasCAcertsPath bool javaHome string cacertsPath string @@ -45,10 +46,12 @@ func init() { } if pathExists(filepath.Join(v, "lib", "security", "cacerts")) { + hasCAcertsPath = true cacertsPath = filepath.Join(v, "lib", "security", "cacerts") } if pathExists(filepath.Join(v, "jre", "lib", "security", "cacerts")) { + hasCAcertsPath = true cacertsPath = filepath.Join(v, "jre", "lib", "security", "cacerts") } } @@ -59,6 +62,10 @@ func (m *mkcert) checkJava() bool { return false } + if !hasCAcertsPath { + return false + } + // exists returns true if the given x509.Certificate's fingerprint // is in the keytool -list output exists := func(c *x509.Certificate, h hash.Hash, keytoolOutput []byte) bool {