From 52daaafdd6f7da76659d033a06183df9fd23d292 Mon Sep 17 00:00:00 2001 From: Carlo Tafuro Date: Tue, 21 Jan 2025 20:26:06 +0100 Subject: [PATCH] test if cacertsPath exists --- truststore_java.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/truststore_java.go b/truststore_java.go index 8ad84bba..cf782d6d 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 {