Blame pr2888-openjdk_should_check_for_system_cacerts_database_eg_etc_pki_java_cacerts.patch

4821c3
# HG changeset patch
4821c3
# User andrew
4821c3
# Date 1459487045 -3600
4821c3
#      Fri Apr 01 06:04:05 2016 +0100
4821c3
# Node ID 3334efeacd8327a14b7d2f392f4546e3c29c594b
4821c3
# Parent  6b81fd2227d14226f2121f2d51b464536925686e
4821c3
PR2888: OpenJDK should check for system cacerts database (e.g. /etc/pki/java/cacerts)
4821c3
4821c3
diff --git a/src/share/classes/sun/security/ssl/TrustManagerFactoryImpl.java b/src/share/classes/sun/security/ssl/TrustManagerFactoryImpl.java
4821c3
--- openjdk/jdk/src/share/classes/sun/security/ssl/TrustManagerFactoryImpl.java
4821c3
+++ openjdk/jdk/src/share/classes/sun/security/ssl/TrustManagerFactoryImpl.java
4821c3
@@ -174,15 +174,20 @@
4821c3
                     storeFile = new File(storeFileName);
4821c3
                     fis = getFileInputStream(storeFile);
4821c3
                 } else {
4821c3
-                    String javaHome = props.get("javaHome");
4821c3
-                    storeFile = new File(javaHome + sep + "lib" + sep
4821c3
-                                                    + "security" + sep +
4821c3
-                                                    "jssecacerts");
4821c3
+                    /* Check system cacerts DB first; /etc/pki/java/cacerts */
4821c3
+                    storeFile = new File(sep + "etc" + sep + "pki" + sep
4821c3
+                                         + "java" + sep + "cacerts");
4821c3
                     if ((fis = getFileInputStream(storeFile)) == null) {
4821c3
+                        String javaHome = props.get("javaHome");
4821c3
                         storeFile = new File(javaHome + sep + "lib" + sep
4821c3
-                                                    + "security" + sep +
4821c3
-                                                    "cacerts");
4821c3
-                        fis = getFileInputStream(storeFile);
4821c3
+                                             + "security" + sep +
4821c3
+                                             "jssecacerts");
4821c3
+                        if ((fis = getFileInputStream(storeFile)) == null) {
4821c3
+                            storeFile = new File(javaHome + sep + "lib" + sep
4821c3
+                                                 + "security" + sep +
4821c3
+                                                 "cacerts");
4821c3
+                            fis = getFileInputStream(storeFile);
4821c3
+                        }
4821c3
                     }
4821c3
                 }
4821c3
 
4821c3
diff --git a/src/share/classes/sun/security/tools/KeyStoreUtil.java b/src/share/classes/sun/security/tools/KeyStoreUtil.java
4821c3
--- openjdk/jdk/src/share/classes/sun/security/tools/KeyStoreUtil.java
4821c3
+++ openjdk/jdk/src/share/classes/sun/security/tools/KeyStoreUtil.java
4821c3
@@ -87,9 +87,14 @@
4821c3
         throws Exception
4821c3
     {
4821c3
         String sep = File.separator;
4821c3
-        File file = new File(System.getProperty("java.home") + sep
4821c3
-                             + "lib" + sep + "security" + sep
4821c3
-                             + "cacerts");
4821c3
+        /* Check system cacerts DB first; /etc/pki/java/cacerts */
4821c3
+        File file = new File(sep + "etc" + sep + "pki" + sep
4821c3
+                             + "java" + sep + "cacerts");
4821c3
+        if (!file.exists()) {
4821c3
+            file = new File(System.getProperty("java.home") + sep
4821c3
+                            + "lib" + sep + "security" + sep
4821c3
+                            + "cacerts");
4821c3
+        }
4821c3
         if (!file.exists()) {
4821c3
             return null;
4821c3
         }