File system-crypto-policy.patch of Package java-11-openjdk.22077

--- a/src/java.base/share/classes/java/security/Security.java
+++ b/src/java.base/share/classes/java/security/Security.java
@@ -47,6 +47,9 @@ import sun.security.jca.*;
  * implementation-specific location, which is typically the properties file
  * {@code conf/security/java.security} in the Java installation directory.
  *
+ * <p>Additional default values of security properties are read from a
+ * system-specific location, if available.</p>
+ *
  * @author Benjamin Renaud
  * @since 1.1
  */
@@ -57,6 +60,10 @@ public final class Security {
     private static final Debug sdebug =
                         Debug.getInstance("properties");
 
+    /* System property file*/
+    private static final String SYSTEM_PROPERTIES =
+        "/etc/crypto-policies/back-ends/java.config";
+
     /* The java.security properties */
     private static Properties props;
 
@@ -98,6 +105,7 @@ public final class Security {
                 if (sdebug != null) {
                     sdebug.println("reading security properties file: " +
                                 propFile);
+                    sdebug.println(props.toString());
                 }
             } catch (IOException e) {
                 if (sdebug != null) {
@@ -184,6 +192,33 @@ public final class Security {
             }
         }
 
+        String disableSystemProps = System.getProperty("java.security.disableSystemPropertiesFile");
+        if (disableSystemProps == null &&
+            "true".equalsIgnoreCase(props.getProperty
+                ("security.useSystemPropertiesFile"))) {
+
+            // now load the system file, if it exists, so its values
+            // will win if they conflict with the earlier values
+            try (BufferedInputStream bis =
+                 new BufferedInputStream(new FileInputStream(SYSTEM_PROPERTIES))) {
+                props.load(bis);
+                loadedProps = true;
+
+                if (sdebug != null) {
+                    sdebug.println("reading system security properties file " +
+                                   SYSTEM_PROPERTIES);
+                    sdebug.println(props.toString());
+                }
+            } catch (IOException e) {
+                if (sdebug != null) {
+                    sdebug.println
+                        ("unable to load security properties from " +
+                         SYSTEM_PROPERTIES);
+                    e.printStackTrace();
+                }
+            }
+        }
+
         if (!loadedProps) {
             initializeStatic();
             if (sdebug != null) {
--- a/src/java.base/share/conf/security/java.security
+++ b/src/java.base/share/conf/security/java.security
@@ -335,6 +335,13 @@ package.definition=sun.misc.,\
 #
 security.overridePropertiesFile=true
 
+#
+# Determines whether this properties file will be appended to
+# using the system properties file stored at
+# /etc/crypto-policies/back-ends/java.config
+#
+security.useSystemPropertiesFile=true
+
 #
 # Determines the default key and trust manager factory algorithms for
 # the javax.net.ssl package.

openSUSE Build Service is sponsored by