Blame SOURCES/pr3694-rh1340845-support_fedora_rhel_system_crypto_policy.patch

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

Additional default values of security properties are read from a

673b76
+ * system-specific location, if available.

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