Blame SOURCES/pr3183-rh1340845-support_fedora_rhel_system_crypto_policy.patch

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

Additional default values of security properties are read from a

8f4f46
+ * system-specific location, if available.

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