|
|
988ad7 |
commit 0cd8cee94fe0f867b0b39890e00be620af1d9b07
|
|
|
988ad7 |
Author: Andrew Hughes <gnu.andrew@redhat.com>
|
|
|
988ad7 |
Date: Tue Jan 18 02:09:27 2022 +0000
|
|
|
988ad7 |
|
|
|
988ad7 |
RH2021263: Improve Security initialisation, now FIPS support no longer relies on crypto policy support
|
|
|
988ad7 |
|
|
|
988ad7 |
diff --git openjdk.orig/src/java.base/share/classes/java/security/Security.java openjdk/src/java.base/share/classes/java/security/Security.java
|
|
|
988ad7 |
index 28ab1846173..f9726741afd 100644
|
|
|
988ad7 |
--- openjdk.orig/src/java.base/share/classes/java/security/Security.java
|
|
|
988ad7 |
+++ openjdk/src/java.base/share/classes/java/security/Security.java
|
|
|
988ad7 |
@@ -61,10 +61,6 @@ public final class Security {
|
|
|
988ad7 |
private static final Debug sdebug =
|
|
|
988ad7 |
Debug.getInstance("properties");
|
|
|
988ad7 |
|
|
|
988ad7 |
- /* System property file*/
|
|
|
988ad7 |
- private static final String SYSTEM_PROPERTIES =
|
|
|
988ad7 |
- "/etc/crypto-policies/back-ends/java.config";
|
|
|
988ad7 |
-
|
|
|
988ad7 |
/* The java.security properties */
|
|
|
988ad7 |
private static Properties props;
|
|
|
988ad7 |
|
|
|
988ad7 |
@@ -206,22 +202,36 @@ public final class Security {
|
|
|
988ad7 |
}
|
|
|
988ad7 |
}
|
|
|
988ad7 |
|
|
|
988ad7 |
+ if (!loadedProps) {
|
|
|
988ad7 |
+ initializeStatic();
|
|
|
988ad7 |
+ if (sdebug != null) {
|
|
|
988ad7 |
+ sdebug.println("unable to load security properties " +
|
|
|
988ad7 |
+ "-- using defaults");
|
|
|
988ad7 |
+ }
|
|
|
988ad7 |
+ }
|
|
|
988ad7 |
+
|
|
|
988ad7 |
String disableSystemProps = System.getProperty("java.security.disableSystemPropertiesFile");
|
|
|
988ad7 |
if ((disableSystemProps == null || "false".equalsIgnoreCase(disableSystemProps)) &&
|
|
|
988ad7 |
"true".equalsIgnoreCase(props.getProperty("security.useSystemPropertiesFile"))) {
|
|
|
988ad7 |
- if (SystemConfigurator.configure(props)) {
|
|
|
988ad7 |
- loadedProps = true;
|
|
|
988ad7 |
+ if (!SystemConfigurator.configureSysProps(props)) {
|
|
|
988ad7 |
+ if (sdebug != null) {
|
|
|
988ad7 |
+ sdebug.println("WARNING: System properties could not be loaded.");
|
|
|
988ad7 |
+ }
|
|
|
988ad7 |
}
|
|
|
988ad7 |
}
|
|
|
988ad7 |
|
|
|
988ad7 |
- if (!loadedProps) {
|
|
|
988ad7 |
- initializeStatic();
|
|
|
988ad7 |
+ // FIPS support depends on the contents of java.security so
|
|
|
988ad7 |
+ // ensure it has loaded first
|
|
|
988ad7 |
+ if (loadedProps) {
|
|
|
988ad7 |
+ boolean fipsEnabled = SystemConfigurator.configureFIPS(props);
|
|
|
988ad7 |
if (sdebug != null) {
|
|
|
988ad7 |
- sdebug.println("unable to load security properties " +
|
|
|
988ad7 |
- "-- using defaults");
|
|
|
988ad7 |
+ if (fipsEnabled) {
|
|
|
988ad7 |
+ sdebug.println("FIPS support enabled.");
|
|
|
988ad7 |
+ } else {
|
|
|
988ad7 |
+ sdebug.println("FIPS support disabled.");
|
|
|
988ad7 |
+ }
|
|
|
988ad7 |
}
|
|
|
988ad7 |
}
|
|
|
988ad7 |
-
|
|
|
988ad7 |
}
|
|
|
988ad7 |
|
|
|
988ad7 |
/*
|
|
|
988ad7 |
diff --git openjdk.orig/src/java.base/share/classes/java/security/SystemConfigurator.java openjdk/src/java.base/share/classes/java/security/SystemConfigurator.java
|
|
|
988ad7 |
index 874c6221ebe..b7ed41acf0f 100644
|
|
|
988ad7 |
--- openjdk.orig/src/java.base/share/classes/java/security/SystemConfigurator.java
|
|
|
988ad7 |
+++ openjdk/src/java.base/share/classes/java/security/SystemConfigurator.java
|
|
|
988ad7 |
@@ -76,7 +76,7 @@ final class SystemConfigurator {
|
|
|
988ad7 |
* java.security.disableSystemPropertiesFile property is not set and
|
|
|
988ad7 |
* security.useSystemPropertiesFile is true.
|
|
|
988ad7 |
*/
|
|
|
988ad7 |
- static boolean configure(Properties props) {
|
|
|
988ad7 |
+ static boolean configureSysProps(Properties props) {
|
|
|
988ad7 |
boolean loadedProps = false;
|
|
|
988ad7 |
|
|
|
988ad7 |
try (BufferedInputStream bis =
|
|
|
988ad7 |
@@ -96,11 +96,19 @@ final class SystemConfigurator {
|
|
|
988ad7 |
e.printStackTrace();
|
|
|
988ad7 |
}
|
|
|
988ad7 |
}
|
|
|
988ad7 |
+ return loadedProps;
|
|
|
988ad7 |
+ }
|
|
|
988ad7 |
+
|
|
|
988ad7 |
+ /*
|
|
|
988ad7 |
+ * Invoked at the end of java.security.Security initialisation
|
|
|
988ad7 |
+ * if java.security properties have been loaded
|
|
|
988ad7 |
+ */
|
|
|
988ad7 |
+ static boolean configureFIPS(Properties props) {
|
|
|
988ad7 |
+ boolean loadedProps = false;
|
|
|
988ad7 |
|
|
|
988ad7 |
try {
|
|
|
988ad7 |
if (enableFips()) {
|
|
|
988ad7 |
if (sdebug != null) { sdebug.println("FIPS mode detected"); }
|
|
|
988ad7 |
- loadedProps = false;
|
|
|
988ad7 |
// Remove all security providers
|
|
|
988ad7 |
Iterator<Entry<Object, Object>> i = props.entrySet().iterator();
|
|
|
988ad7 |
while (i.hasNext()) {
|