Blame SOURCES/pr3183-rh1340845-support_fedora_rhel_system_crypto_policy.patch

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

Additional default values of security properties are read from a

f8e459
+ * system-specific location, if available.

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