From c8057b3b01baeaa10fcb075260901e63fdce449f Mon Sep 17 00:00:00 2001 From: mo khan Date: Tue, 15 Sep 2020 16:34:19 -0600 Subject: fix: install x509 cert into java 11 keystore --- lib/license/management/tool_box.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/license/management/tool_box.rb b/lib/license/management/tool_box.rb index 0e39a61..4c41b36 100644 --- a/lib/license/management/tool_box.rb +++ b/lib/license/management/tool_box.rb @@ -26,7 +26,7 @@ module License shell.execute([:asdf, :reshim], env: env) end install_common_libraries(env: env) if C_BASED_TOOLS.include?(tool.to_sym) - install_certificates_into_java_keystore(env) if tool == :java + install_certificates_into_java_keystore(env, version) if tool == :java end def install_common_libraries(env: {}) @@ -116,10 +116,11 @@ module License asdf_detected_version_of(:java) end - def install_certificates_into_java_keystore(env) + def install_certificates_into_java_keystore(env, version) Dir.chdir shell.custom_certificate_path.dirname do Dir.glob('custom.*.crt').each do |path| - keystore_path = "#{env['JAVA_HOME']}/jre/lib/security/cacerts" + java_home = Pathname.new(env['JAVA_HOME']) + keystore_path = "8" == version ? java_home.join("jre/lib/security/cacerts") : java_home.join("lib/security/cacerts") shell.execute([:keytool, '-importcert', '-alias', Time.now.to_i, '-file', File.expand_path(path), '-trustcacerts', '-noprompt', '-storepass', 'changeit', '-keystore', keystore_path], env: env) shell.execute([:keytool, '-list', '-v', '-storepass changeit', '-keystore', keystore_path], env: env) end -- cgit v1.2.3