Blame pr3183-rh1340845-support_fedora_rhel_system_crypto_policy.patch

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

Additional default values of security properties are read from a

2ffe923
+ * system-specific location, if available.

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