Blame SOURCES/pr3694-rh1340845-support_fedora_rhel_system_crypto_policy.patch

67e3c5
67e3c5
# HG changeset patch
67e3c5
# User andrew
67e3c5
# Date 1478057514 0
67e3c5
# Node ID 1c4d5cb2096ae55106111da200b0bcad304f650c
67e3c5
# Parent  3d53f19b48384e5252f4ec8891f7a3a82d77af2a
67e3c5
PR3694: Support Fedora/RHEL system crypto policy
67e3c5
diff -r 3d53f19b4838 -r 1c4d5cb2096a src/java.base/share/classes/java/security/Security.java
67e3c5
--- a/src/java.base/share/classes/java/security/Security.java	Wed Oct 26 03:51:39 2016 +0100
67e3c5
+++ b/src/java.base/share/classes/java/security/Security.java	Wed Nov 02 03:31:54 2016 +0000
67e3c5
@@ -43,6 +43,9 @@
67e3c5
  * implementation-specific location, which is typically the properties file
67e3c5
  * {@code conf/security/java.security} in the Java installation directory.
67e3c5
  *
67e3c5
+ * 

Additional default values of security properties are read from a

67e3c5
+ * system-specific location, if available.

67e3c5
+ *
67e3c5
  * @author Benjamin Renaud
67e3c5
  * @since 1.1
67e3c5
  */
67e3c5
@@ -52,6 +55,10 @@
67e3c5
     private static final Debug sdebug =
67e3c5
                         Debug.getInstance("properties");
67e3c5
 
67e3c5
+    /* System property file*/
67e3c5
+    private static final String SYSTEM_PROPERTIES =
67e3c5
+        "/etc/crypto-policies/back-ends/java.config";
67e3c5
+
67e3c5
     /* The java.security properties */
67e3c5
     private static Properties props;
67e3c5
 
67e3c5
@@ -93,6 +100,7 @@
67e3c5
                 if (sdebug != null) {
67e3c5
                     sdebug.println("reading security properties file: " +
67e3c5
                                 propFile);
67e3c5
+                    sdebug.println(props.toString());
67e3c5
                 }
67e3c5
             } catch (IOException e) {
67e3c5
                 if (sdebug != null) {
67e3c5
@@ -114,6 +122,31 @@
67e3c5
         }
67e3c5
 
67e3c5
         if ("true".equalsIgnoreCase(props.getProperty
67e3c5
+                ("security.useSystemPropertiesFile"))) {
67e3c5
+
67e3c5
+            // now load the system file, if it exists, so its values
67e3c5
+            // will win if they conflict with the earlier values
67e3c5
+            try (BufferedInputStream bis =
67e3c5
+                 new BufferedInputStream(new FileInputStream(SYSTEM_PROPERTIES))) {
67e3c5
+                props.load(bis);
67e3c5
+                loadedProps = true;
67e3c5
+
67e3c5
+                if (sdebug != null) {
67e3c5
+                    sdebug.println("reading system security properties file " +
67e3c5
+                                   SYSTEM_PROPERTIES);
67e3c5
+                    sdebug.println(props.toString());
67e3c5
+                }
67e3c5
+            } catch (IOException e) {
67e3c5
+                if (sdebug != null) {
67e3c5
+                    sdebug.println
67e3c5
+                        ("unable to load security properties from " +
67e3c5
+                         SYSTEM_PROPERTIES);
67e3c5
+                    e.printStackTrace();
67e3c5
+                }
67e3c5
+            }
67e3c5
+        }
67e3c5
+
67e3c5
+        if ("true".equalsIgnoreCase(props.getProperty
67e3c5
                 ("security.overridePropertiesFile"))) {
67e3c5
 
67e3c5
             String extraPropFile = System.getProperty
67e3c5
diff -r 3d53f19b4838 -r 1c4d5cb2096a src/java.base/share/conf/security/java.security
67e3c5
--- a/src/java.base/share/conf/security/java.security	Wed Oct 26 03:51:39 2016 +0100
67e3c5
+++ b/src/java.base/share/conf/security/java.security	Wed Nov 02 03:31:54 2016 +0000
67e3c5
@@ -276,6 +276,13 @@
67e3c5
 security.overridePropertiesFile=true
67e3c5
 
67e3c5
 #
67e3c5
+# Determines whether this properties file will be appended to
67e3c5
+# using the system properties file stored at
67e3c5
+# /etc/crypto-policies/back-ends/java.config
67e3c5
+#
67e3c5
+security.useSystemPropertiesFile=true
67e3c5
+
67e3c5
+#
67e3c5
 # Determines the default key and trust manager factory algorithms for
67e3c5
 # the javax.net.ssl package.
67e3c5
 #