mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 15:17:30 -04:00
Test adjustments for FIPS 140 (#56526)
This change aims to fix our setup in CI so that we can run 7.x in FIPS 140 mode. The major issue that we have in 7.x and did not have in master is that we can't use the diagnostic trust manager in FIPS mode in Java 8 with SunJSSE in FIPS approved mode as it explicitly disallows the wrapping of X509TrustManager. Previous attempts like #56427 and #52211 focused on disabling the setting in all of our tests when creating a Settings object or on setting fips_mode.enabled accordingly (which implicitly disables the diagnostic trust manager). The attempts weren't future proof though as nothing would forbid someone to add new tests without setting the necessary setting and forcing this would be very inconvenient for any other case ( see #56427 (comment) for the full argumentation). This change introduces a runtime check in SSLService that overrides the configuration value of xpack.security.ssl.diagnose.trust and disables the diagnostic trust manager when we are running in Java 8 and the SunJSSE provider is set in FIPS mode.
This commit is contained in:
parent
2a21d4d976
commit
239ada1669
8 changed files with 89 additions and 27 deletions
|
@ -64,12 +64,34 @@ task writeTestJavaPolicy {
|
|||
throw new GradleException("failed to create temporary directory [${tmp}]")
|
||||
}
|
||||
final File javaPolicy = file("${tmp}/java.policy")
|
||||
javaPolicy.write(
|
||||
[
|
||||
"grant {",
|
||||
" permission java.util.PropertyPermission \"com.amazonaws.sdk.ec2MetadataServiceEndpointOverride\", \"write\";",
|
||||
"};"
|
||||
].join("\n"))
|
||||
if (BuildParams.inFipsJvm) {
|
||||
javaPolicy.write(
|
||||
[
|
||||
"grant {",
|
||||
" permission java.security.SecurityPermission \"putProviderProperty.BCFIPS\";",
|
||||
" permission java.security.SecurityPermission \"putProviderProperty.BCJSSE\";",
|
||||
" permission java.lang.RuntimePermission \"getProtectionDomain\";",
|
||||
" permission java.util.PropertyPermission \"java.runtime.name\", \"read\";",
|
||||
" permission org.bouncycastle.crypto.CryptoServicesPermission \"tlsAlgorithmsEnabled\";",
|
||||
" permission java.lang.RuntimePermission \"accessClassInPackage.sun.security.internal.spec\";",
|
||||
" permission java.lang.RuntimePermission \"accessDeclaredMembers\";",
|
||||
" permission java.util.PropertyPermission \"intellij.debug.agent\", \"read\";",
|
||||
" permission java.util.PropertyPermission \"intellij.debug.agent\", \"write\";",
|
||||
" permission org.bouncycastle.crypto.CryptoServicesPermission \"exportSecretKey\";",
|
||||
" permission org.bouncycastle.crypto.CryptoServicesPermission \"exportPrivateKey\";",
|
||||
" permission java.io.FilePermission \"\${javax.net.ssl.trustStore}\", \"read\";",
|
||||
" permission java.util.PropertyPermission \"com.amazonaws.sdk.ec2MetadataServiceEndpointOverride\", \"write\";",
|
||||
"};"
|
||||
].join("\n")
|
||||
)
|
||||
} else {
|
||||
javaPolicy.write(
|
||||
[
|
||||
"grant {",
|
||||
" permission java.util.PropertyPermission \"com.amazonaws.sdk.ec2MetadataServiceEndpointOverride\", \"write\";",
|
||||
"};"
|
||||
].join("\n"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,9 +100,15 @@ test {
|
|||
// this is needed for insecure plugins, remove if possible!
|
||||
systemProperty 'tests.artifact', project.name
|
||||
|
||||
// this is needed to manipulate com.amazonaws.sdk.ec2MetadataServiceEndpointOverride system property
|
||||
// Setting a custom policy to manipulate com.amazonaws.sdk.ec2MetadataServiceEndpointOverride system property
|
||||
// it is better rather disable security manager at all with `systemProperty 'tests.security.manager', 'false'`
|
||||
systemProperty 'java.security.policy', "file://${buildDir}/tmp/java.policy"
|
||||
if (BuildParams.inFipsJvm){
|
||||
// Using the key==value format to override default JVM security settings and policy
|
||||
// see also: https://docs.oracle.com/javase/8/docs/technotes/guides/security/PolicyFiles.html
|
||||
systemProperty 'java.security.policy', "=file://${buildDir}/tmp/java.policy"
|
||||
} else {
|
||||
systemProperty 'java.security.policy', "file://${buildDir}/tmp/java.policy"
|
||||
}
|
||||
}
|
||||
|
||||
check {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue