Skip to content

Ensure Security class is loaded when checking FIPS mode#23490

Open
dev-koan wants to merge 1 commit intoeclipse-openj9:masterfrom
dev-koan:feature/SystemFIPSModeCheck
Open

Ensure Security class is loaded when checking FIPS mode#23490
dev-koan wants to merge 1 commit intoeclipse-openj9:masterfrom
dev-koan:feature/SystemFIPSModeCheck

Conversation

@dev-koan
Copy link

@dev-koan dev-koan commented Mar 11, 2026

Initialize security class when accessing com.ibm.fips.mode property or obtaining all the properties using the method getProperties.

Signed-off-by: Dev Agarwal [email protected]

@dev-koan
Copy link
Author

The feature is tested in PR => ibmruntimes/openj9-openjdk-jdk#1185

@pshipton
Copy link
Member

@jasonkatonica I thought we were going to use a Security property rather than a System property.

@jasonkatonica
Copy link
Contributor

After talking more yesterday at our team meeting we want to support a System property, not a Security property. This property wont be a direct value that is typically in a java.security file and available through the Security class.

We also want applications who have coded to this behavior in IBM Java 8 ( and Semeru ) to not be required to make changes in this area. Sure this property does not always work today given the classloading race condition here however further discussion flushed out that we really want to support this as a System property if possible.

@jasonkatonica
Copy link
Contributor

We would like to support our existing documented behavior in section Java properties and other external interfaces at https://www.ibm.com/support/pages/node/7113528

@keithc-ca
Copy link
Contributor

support our existing documented behavior

That documentation doesn't specifically say how to acquire the system property value. As is, this doesn't guarantee that System.getProperties().getProperty("com.ibm.fips.mode") yields the desired value.

@jasonkatonica
Copy link
Contributor

jasonkatonica commented Mar 11, 2026

That documentation doesn't specifically say how to acquire the system property value. As is, this doesn't guarantee that System.getProperties().getProperty("com.ibm.fips.mode") yields the desired value.

Yes very true likely additional work would be needed for this corner case to ensure we reference the Security class that makes this value accurate for the api you describe for com.ibm.fips.mode

@dev-koan dev-koan force-pushed the feature/SystemFIPSModeCheck branch from d1a14bd to d3d78de Compare March 11, 2026 17:31
@keithc-ca
Copy link
Contributor

The commit message and the description here need not mention RestrictedSecurity.

@dev-koan dev-koan force-pushed the feature/SystemFIPSModeCheck branch from d3d78de to 8314680 Compare March 11, 2026 20:45
@dev-koan dev-koan changed the title Ensure Security and RestrictedSecurity is loaded when checking FIPS mode Ensure Security is loaded when checking FIPS mode Mar 11, 2026
@keithc-ca
Copy link
Contributor

The commit message says this forces "initialization of Security providers"; that is no longer true. Please update accordingly.

This still doesn't address my earlier concern: #23490 (comment). Unless that is fixed (in a reasonable way), I think we should instead advise users to use Security.getProperty("com.ibm.fips.mode") which can more easily be made to work reliably.

Initialize security class when accessing com.ibm.fips.mode
property or obtaining all the properties using the method
getProperties.

Signed-off-by: Dev Agarwal <[email protected]>
@dev-koan dev-koan force-pushed the feature/SystemFIPSModeCheck branch from 8314680 to 3c675e1 Compare March 13, 2026 18:51
@dev-koan dev-koan changed the title Ensure Security is loaded when checking FIPS mode Ensure Security class is loaded when checking FIPS mode Mar 13, 2026
@dev-koan
Copy link
Author

dev-koan commented Mar 13, 2026

The commit message says this forces "initialization of Security providers"; that is no longer true. Please update accordingly.

This still doesn't address my earlier concern: #23490 (comment). Unless that is fixed (in a reasonable way), I think we should instead advise users to use Security.getProperty("com.ibm.fips.mode") which can more easily be made to work reliably.

The commit has been updated.
I have added J9VMInternals.initialize(Security.class); in the getProperties() to make sure Security class is initialized. (When security class is initialized systemProperties is also updated.)

security.checkPropertiesAccess();
}
/*[ENDIF] JAVA_SPEC_VERSION < 24 */
J9VMInternals.initialize(Security.class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change below to getProperty(String, String) will only trigger loading Security if the property of interest is "com.ibm.fips.mode"; while this has the potential to affect startup performance for every application, including those that don't use Security. I'm having difficulty accepting that instead of changing our advice for querying the FIPS mode via a system property to using Security.getProperty("com.ibm.fips.mode").

@pshipton What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not ideal and using a Security property would be better, but I doubt the change in startup time would be measurable. If this is what we need to do for compatibility, so be it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants