Skip to content

Commit

Permalink
Merge pull request #1 from carlotafuro/carlotafuro-patch-truststore_java
Browse files Browse the repository at this point in the history
test if cacertsPath exists
  • Loading branch information
carlotafuro authored Jan 21, 2025
2 parents 1c1dc4e + 52daaaf commit 8762974
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions truststore_java.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import (
)

var (
hasJava bool
hasKeytool bool
hasJava bool
hasKeytool bool
hasCAcertsPath bool

javaHome string
cacertsPath string
Expand All @@ -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")
}
}
Expand All @@ -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 {
Expand Down

0 comments on commit 8762974

Please sign in to comment.