Blame SOURCES/pr2888.patch

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