Blame SOURCES/pr3183-rh1340845-support_fedora_rhel_system_crypto_policy.patch

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

Additional default values of security properties are read from a

c0c534
+ * system-specific location, if available.

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