Skip to content

Commit 9501d77

Browse files
committed
Enable FIPS entitlements based on org.bouncycastle.fips.approved_only.
When enabling FIPS `javax.net.ssl.trustStore` is not necessarily set. This change adds FIPS entitlements based on `org.bouncycastle.fips.approved_only=true`, which enforces usage of FIPS approved functionality only. Additionally, this PR grants read access to a custom trust store if provided via `javax.net.ssl.trustStore`, otherwise read access to the default JDK trust store is granted. Relates to ES-11025.
1 parent 6cb5f83 commit 9501d77

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

libs/entitlement/src/main/java/org/elasticsearch/entitlement/initialization/EntitlementInitialization.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -241,16 +241,19 @@ private static PolicyManager createPolicyManager() {
241241
)
242242
);
243243

244-
Path trustStorePath = trustStorePath();
245-
if (trustStorePath != null) {
244+
// conditionally add FIPS entitlements if FIPS only functionality is enforced
245+
if ("true".equals(System.getProperty("org.bouncycastle.fips.approved_only"))) {
246+
// if custom trust store is set, grant read access to its location, otherwise use the default trust store
247+
String trustStore = System.getProperty("javax.net.ssl.trustStore");
248+
Path trustStorePath = trustStore != null ? Path.of(trustStore) : bootstrapArgs.libDir().resolve("security/jssecacerts");
246249
Collections.addAll(
247250
serverScopes,
248251
new Scope(
249252
"org.bouncycastle.fips.tls",
250253
List.of(
251254
new FilesEntitlement(List.of(FileData.ofPath(trustStorePath, READ))),
252-
new OutboundNetworkEntitlement(),
253-
new ManageThreadsEntitlement()
255+
new ManageThreadsEntitlement(),
256+
new OutboundNetworkEntitlement()
254257
)
255258
),
256259
new Scope(
@@ -302,11 +305,6 @@ private static Path getUserHome() {
302305
return PathUtils.get(userHome);
303306
}
304307

305-
private static Path trustStorePath() {
306-
String trustStore = System.getProperty("javax.net.ssl.trustStore");
307-
return trustStore != null ? Path.of(trustStore) : null;
308-
}
309-
310308
private static Stream<InstrumentationService.InstrumentationInfo> fileSystemProviderChecks() throws ClassNotFoundException,
311309
NoSuchMethodException {
312310
var fileSystemProviderClass = FileSystems.getDefault().provider().getClass();

0 commit comments

Comments
 (0)