Blame SOURCES/pr2888-rh2055274-support_system_cacerts-8139f2361c2.patch

9dbea9
diff --git a/jdk/src/share/classes/sun/security/ssl/TrustStoreManager.java b/jdk/src/share/classes/sun/security/ssl/TrustStoreManager.java
9dbea9
index e7b4763db53..0005e56f528 100644
9dbea9
--- a/jdk/src/share/classes/sun/security/ssl/TrustStoreManager.java
9dbea9
+++ b/jdk/src/share/classes/sun/security/ssl/TrustStoreManager.java
9dbea9
@@ -31,6 +31,7 @@ import java.security.*;
9dbea9
 import java.security.cert.*;
9dbea9
 import java.util.*;
9dbea9
 import sun.security.action.*;
9dbea9
+import sun.security.tools.KeyStoreUtil;
9dbea9
 import sun.security.validator.TrustStoreUtil;
9dbea9
 
9dbea9
 /**
9dbea9
@@ -68,7 +69,7 @@ final class TrustStoreManager {
9dbea9
      * The preference of the default trusted KeyStore is:
9dbea9
      *    javax.net.ssl.trustStore
9dbea9
      *    jssecacerts
9dbea9
-     *    cacerts
9dbea9
+     *    cacerts (system and local)
9dbea9
      */
9dbea9
     private static final class TrustStoreDescriptor {
9dbea9
         private static final String fileSep = File.separator;
9dbea9
@@ -76,7 +77,8 @@ final class TrustStoreManager {
9dbea9
                 GetPropertyAction.privilegedGetProperty("java.home") +
9dbea9
                 fileSep + "lib" + fileSep + "security";
9dbea9
         private static final String defaultStore =
9dbea9
-                defaultStorePath + fileSep + "cacerts";
9dbea9
+                AccessController.doPrivileged((PrivilegedAction<String>) () ->
9dbea9
+                        KeyStoreUtil.getCacertsKeyStorePath());
9dbea9
         private static final String jsseDefaultStore =
9dbea9
                 defaultStorePath + fileSep + "jssecacerts";
9dbea9
 
9dbea9
@@ -139,6 +141,10 @@ final class TrustStoreManager {
9dbea9
                     String storePropPassword = System.getProperty(
9dbea9
                             "javax.net.ssl.trustStorePassword", "");
9dbea9
 
9dbea9
+                    if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) {
9dbea9
+                        SSLLogger.fine("Default store: " + defaultStore);
9dbea9
+                    }
9dbea9
+
9dbea9
                     String temporaryName = "";
9dbea9
                     File temporaryFile = null;
9dbea9
                     long temporaryTime = 0L;
9dbea9
@@ -160,7 +166,7 @@ final class TrustStoreManager {
9dbea9
                                     SSLLogger.isOn("trustmanager")) {
9dbea9
                                 SSLLogger.fine(
9dbea9
                                         "Inaccessible trust store: " +
9dbea9
-                                        storePropName);
9dbea9
+                                        fileName);
9dbea9
                             }
9dbea9
                         }
9dbea9
                     } else {
9dbea9
diff --git a/jdk/src/share/classes/sun/security/tools/KeyStoreUtil.java b/jdk/src/share/classes/sun/security/tools/KeyStoreUtil.java
9dbea9
index fcc77786da1..3a4388964cc 100644
9dbea9
--- a/jdk/src/share/classes/sun/security/tools/KeyStoreUtil.java
9dbea9
+++ b/jdk/src/share/classes/sun/security/tools/KeyStoreUtil.java
9dbea9
@@ -41,6 +41,8 @@ import java.text.Collator;
9dbea9
 import java.util.Locale;
9dbea9
 import java.util.ResourceBundle;
9dbea9
 
9dbea9
+import sun.security.util.SecurityProperties;
9dbea9
+
9dbea9
 /**
9dbea9
  * 

This class provides several utilities to KeyStore.

9dbea9
  *
9dbea9
@@ -54,6 +56,8 @@ public class KeyStoreUtil {
9dbea9
 
9dbea9
     private static final String JKS = "jks";
9dbea9
 
9dbea9
+    private static final String SYSTEM_CA_CERTS_PROP = "security.systemCACerts";
9dbea9
+
9dbea9
     /**
9dbea9
      * Returns true if the certificate is self-signed, false otherwise.
9dbea9
      */
9dbea9
@@ -96,16 +100,30 @@ public class KeyStoreUtil {
9dbea9
         }
9dbea9
     }
9dbea9
 
9dbea9
+    /**
9dbea9
+     * Returns the path to the cacerts DB
9dbea9
+     */
9dbea9
+    public static String getCacertsKeyStorePath()
9dbea9
+    {
9dbea9
+        // Check system DB first, preferring system property over security one
9dbea9
+        String systemDB = SecurityProperties
9dbea9
+                .privilegedGetOverridable(SYSTEM_CA_CERTS_PROP);
9dbea9
+        if (systemDB != null && !"".equals(systemDB) &&
9dbea9
+                (new File(systemDB)).isFile()) {
9dbea9
+            return systemDB;
9dbea9
+        }
9dbea9
+        String sep = File.separator;
9dbea9
+        return System.getProperty("java.home") + sep
9dbea9
+                + "lib" + sep + "security" + sep + "cacerts";
9dbea9
+    }
9dbea9
+
9dbea9
     /**
9dbea9
      * Returns the keystore with the configured CA certificates.
9dbea9
      */
9dbea9
     public static KeyStore getCacertsKeyStore()
9dbea9
         throws Exception
9dbea9
     {
9dbea9
-        String sep = File.separator;
9dbea9
-        File file = new File(System.getProperty("java.home") + sep
9dbea9
-                             + "lib" + sep + "security" + sep
9dbea9
-                             + "cacerts");
9dbea9
+        File file = new File(getCacertsKeyStorePath());
9dbea9
         if (!file.exists()) {
9dbea9
             return null;
9dbea9
         }
9dbea9
diff --git a/jdk/src/share/lib/security/java.security-aix b/jdk/src/share/lib/security/java.security-aix
9dbea9
index 681a24b905d..ecb8bc43a6c 100644
9dbea9
--- a/jdk/src/share/lib/security/java.security-aix
9dbea9
+++ b/jdk/src/share/lib/security/java.security-aix
9dbea9
@@ -294,6 +294,12 @@ security.overridePropertiesFile=true
9dbea9
 #
9dbea9
 security.useSystemPropertiesFile=false
9dbea9
 
9dbea9
+#
9dbea9
+# Specifies the system certificate store
9dbea9
+# This property may be disabled using an empty value
9dbea9
+#
9dbea9
+security.systemCACerts=${java.home}/lib/security/cacerts
9dbea9
+
9dbea9
 #
9dbea9
 # Determines the default key and trust manager factory algorithms for
9dbea9
 # the javax.net.ssl package.
9dbea9
diff --git a/jdk/src/share/lib/security/java.security-linux b/jdk/src/share/lib/security/java.security-linux
9dbea9
index 789c19a8cba..2546fdec9b2 100644
9dbea9
--- a/jdk/src/share/lib/security/java.security-linux
9dbea9
+++ b/jdk/src/share/lib/security/java.security-linux
9dbea9
@@ -307,6 +307,12 @@ security.overridePropertiesFile=true
9dbea9
 #
9dbea9
 security.useSystemPropertiesFile=false
9dbea9
 
9dbea9
+#
9dbea9
+# Specifies the system certificate store
9dbea9
+# This property may be disabled using an empty value
9dbea9
+#
9dbea9
+security.systemCACerts=${java.home}/lib/security/cacerts
9dbea9
+
9dbea9
 #
9dbea9
 # Determines the default key and trust manager factory algorithms for
9dbea9
 # the javax.net.ssl package.
9dbea9
diff --git a/jdk/src/share/lib/security/java.security-macosx b/jdk/src/share/lib/security/java.security-macosx
9dbea9
index d4da666af3b..1a20027c02b 100644
9dbea9
--- a/jdk/src/share/lib/security/java.security-macosx
9dbea9
+++ b/jdk/src/share/lib/security/java.security-macosx
9dbea9
@@ -297,6 +297,12 @@ security.overridePropertiesFile=true
9dbea9
 #
9dbea9
 security.useSystemPropertiesFile=false
9dbea9
 
9dbea9
+#
9dbea9
+# Specifies the system certificate store
9dbea9
+# This property may be disabled using an empty value
9dbea9
+#
9dbea9
+security.systemCACerts=${java.home}/lib/security/cacerts
9dbea9
+
9dbea9
 #
9dbea9
 # Determines the default key and trust manager factory algorithms for
9dbea9
 # the javax.net.ssl package.
9dbea9
diff --git a/jdk/src/share/lib/security/java.security-solaris b/jdk/src/share/lib/security/java.security-solaris
9dbea9
index 300132384a1..6299e0a3c7b 100644
9dbea9
--- a/jdk/src/share/lib/security/java.security-solaris
9dbea9
+++ b/jdk/src/share/lib/security/java.security-solaris
9dbea9
@@ -295,6 +295,12 @@ security.overridePropertiesFile=true
9dbea9
 #
9dbea9
 security.useSystemPropertiesFile=false
9dbea9
 
9dbea9
+#
9dbea9
+# Specifies the system certificate store
9dbea9
+# This property may be disabled using an empty value
9dbea9
+#
9dbea9
+security.systemCACerts=${java.home}/lib/security/cacerts
9dbea9
+
9dbea9
 #
9dbea9
 # Determines the default key and trust manager factory algorithms for
9dbea9
 # the javax.net.ssl package.
9dbea9
diff --git a/jdk/src/share/lib/security/java.security-windows b/jdk/src/share/lib/security/java.security-windows
9dbea9
index 64db5a5cd1e..823994f3466 100644
9dbea9
--- a/jdk/src/share/lib/security/java.security-windows
9dbea9
+++ b/jdk/src/share/lib/security/java.security-windows
9dbea9
@@ -297,6 +297,12 @@ security.overridePropertiesFile=true
9dbea9
 #
9dbea9
 security.useSystemPropertiesFile=false
9dbea9
 
9dbea9
+#
9dbea9
+# Specifies the system certificate store
9dbea9
+# This property may be disabled using an empty value
9dbea9
+#
9dbea9
+security.systemCACerts=${java.home}/lib/security/cacerts
9dbea9
+
9dbea9
 #
9dbea9
 # Determines the default key and trust manager factory algorithms for
9dbea9
 # the javax.net.ssl package.