Skip to content

Commit 1b2c52a

Browse files
Only check and set FIPS mode in FIPS profiles
A RestrictedSecurity profile doesn't have to be a FIPS profile, in which case a FIPS mode property is not required and the corresponding system property should not be set. Signed-off-by: Kostas Tsiounis <[email protected]>
1 parent 1342650 commit 1b2c52a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

closed/src/java.base/share/classes/openj9/internal/security/RestrictedSecurity.java

+11-5
Original file line numberDiff line numberDiff line change
@@ -558,11 +558,17 @@ private static void setProperties(Properties props) {
558558
propsMapping.put("jdk.tls.legacyAlgorithms", restricts.jdkTlsLegacyAlgorithms);
559559
propsMapping.put("jdk.certpath.disabledAlgorithms", restricts.jdkCertpathDisabledAlgorithms);
560560
propsMapping.put("jdk.security.legacyAlgorithms", restricts.jdkSecurityLegacyAlgorithms);
561-
String fipsMode = System.getProperty("com.ibm.fips.mode");
562-
if (fipsMode == null) {
563-
System.setProperty("com.ibm.fips.mode", restricts.jdkFipsMode);
564-
} else if (!fipsMode.equals(restricts.jdkFipsMode)) {
565-
printStackTraceAndExit("Property com.ibm.fips.mode is incompatible with semeru.customprofile and semeru.fips properties");
561+
562+
if (restricts.descIsFIPS) {
563+
if (restricts.jdkFipsMode == null) {
564+
printStackTraceAndExit(profileID + ".fips.mode property is not set in FIPS profile");
565+
}
566+
String fipsMode = System.getProperty("com.ibm.fips.mode");
567+
if (fipsMode == null) {
568+
System.setProperty("com.ibm.fips.mode", restricts.jdkFipsMode);
569+
} else if (!fipsMode.equals(restricts.jdkFipsMode)) {
570+
printStackTraceAndExit("Property com.ibm.fips.mode is incompatible with semeru.customprofile and semeru.fips properties");
571+
}
566572
}
567573

568574
if (userEnabledFIPS && !allowSetProperties) {

0 commit comments

Comments
 (0)