Blame SOURCES/pr3183-rh1340845-support_fedora_rhel_system_crypto_policy.patch

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

Additional default values of security properties are read from a

d1af5a
+ * system-specific location, if available.

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