Blame pr3694-rh1340845-support_fedora_rhel_system_crypto_policy.patch

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

Additional default values of security properties are read from a

9bc9710
+ * system-specific location, if available.

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