-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test adjustments for FIPS 140 in Java 8 #52211
Conversation
This commit touches many of our tests but the changes are actually few. Setting xpack.security.ssl.diagnose.trust to true wraps SunJSSE TrustManager with our own DiagnosticTrustManager and this is not allowed when SunJSSE is in FIPS mode. So when we use SunJSSE in FIPS mode ( currently only when running our tests with FIPS mode on for Java 8 runtime ), we need to make sure that the Diagnostic TrustManager is not enabled. This change ensures that whenever a new SSLService is to be created, we explicitly pass xpack.security.ssl.diagnose.trust=false in the settings used for the SSLService, when we run in FIPS mode in Java 8.
Pinging @elastic/es-core-infra (:Core/Infra/Build) |
Pinging @elastic/es-security (:Security/Security) |
...lugin/core/src/test/java/org/elasticsearch/xpack/core/ssl/SSLConfigurationReloaderTests.java
Show resolved
Hide resolved
@@ -153,12 +154,17 @@ protected void setLicenseState(XPackLicenseState licenseState) { | |||
NamedXContentRegistry xContentRegistry, Environment environment, | |||
NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { | |||
List<Object> components = new ArrayList<>(); | |||
// This is a hack, but the settings we add in #additionalSettings() are not added to the environment instance | |||
// (in org.elasticsearch.node.Node) which is passed in `createComponents` of each of the plugins. So the environment | |||
// we get here wouldn't have the additional setting. This is a known issue, and once it is resolved, the code here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how we track this and if we have an issue for it ( couldn't find one but I might have failed ) . There was some relevant discussion around this in #49667. Discussed it briefly with @rjernst on slack, and I didn't want to open an issue for this specific case here as it is only part of the problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't sound right to me. Doesn't environment
contain the extra settings here? I think it's supposed to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes environment should have the extra settings. My comment in slack was about the Settings passed into Plugin constructors.
|
@elasticmachine run elasticsearch-ci/default-distro |
importing |
...k/plugin/core/src/test/java/org/elasticsearch/xpack/core/LocalStateCompositeXPackPlugin.java
Show resolved
Hide resolved
|
||
TransportClient client = new PreBuiltXPackTransportClient(clientSettings).addTransportAddresses(transportAddresses); | ||
.put(SecurityField.USER_SETTING.getKey(), "transport_user:x-pack-test-password"); | ||
if (Boolean.parseBoolean(System.getProperty(FIPS_SYSPROP)) && JavaVersion.current().getVersion().get(0) == 8) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you just do this? I tried the import against your branch and it was OK.
if (Boolean.parseBoolean(System.getProperty(FIPS_SYSPROP)) && JavaVersion.current().getVersion().get(0) == 8) { | |
if (inFipsSunJsseJvm()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -67,6 +70,9 @@ private static Client startClient(Path tempDir, TransportAddress... transportAdd | |||
.put("client.transport.ignore_cluster_name", true) | |||
.put("xpack.security.enabled", false) | |||
.put(Environment.PATH_HOME_SETTING.getKey(), tempDir); | |||
if (Boolean.parseBoolean(System.getProperty(FIPS_SYSPROP)) && JavaVersion.current().getVersion().get(0) == 8) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here?
if (Boolean.parseBoolean(System.getProperty(FIPS_SYSPROP)) && JavaVersion.current().getVersion().get(0) == 8) { | |
if (inFipsSunJsseJvm()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #52211 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a comment in code (and preferably a tracking issue) or someone may inadvertently try to make the same obvious change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that makes total sense - I'll make do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I'd like to understand what's going on in createComponents
.
@@ -153,12 +154,17 @@ protected void setLicenseState(XPackLicenseState licenseState) { | |||
NamedXContentRegistry xContentRegistry, Environment environment, | |||
NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { | |||
List<Object> components = new ArrayList<>(); | |||
// This is a hack, but the settings we add in #additionalSettings() are not added to the environment instance | |||
// (in org.elasticsearch.node.Node) which is passed in `createComponents` of each of the plugins. So the environment | |||
// we get here wouldn't have the additional setting. This is a known issue, and once it is resolved, the code here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't sound right to me. Doesn't environment
contain the extra settings here? I think it's supposed to.
...lugin/core/src/test/java/org/elasticsearch/xpack/core/ssl/SSLConfigurationReloaderTests.java
Show resolved
Hide resolved
Happy to explain @tvernum , this tripped me also while troubleshooting the errors. See elasticsearch/server/src/main/java/org/elasticsearch/node/Node.java Lines 271 to 273 in a304d9a
We get the environment in the constructor of the Node Then in elasticsearch/server/src/main/java/org/elasticsearch/node/Node.java Lines 315 to 330 in a304d9a
we call I would think that we then use elasticsearch/server/src/main/java/org/elasticsearch/node/Node.java Lines 454 to 471 in a304d9a
We create the Line 142 in 26b9cf7
doesn't have the additional settings Now, it could be that this is a simple mistake because the method parameter shadows the class field, but @elastic/es-core-infra is aware of this and it made sense to attack this at in a different PR, this my comment in #52211 (comment). HTH |
@rjernst I think I addressed your comment, but pinging for an explicit LGTM just in case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for causing confusion. This does seem like a case where we should use additionalSettings()
.
if (inFipsSunJsseJvm()) { | ||
Settings additionalSettings = Settings.builder() | ||
.put(existingEnvironment.settings()) | ||
.put(XPackSettings.DIAGNOSE_TRUST_EXCEPTIONS_SETTING.getKey(), false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't this be returnned from additionalSettings()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies if I misunderstood @rjernst but did you read through #52211 (comment) ? I'll go and double check this again but this was supposed to show why additionalSettings doesn't solve this here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I missed that explanation. It looks to me like a bug. We should be passing the final environment everywhere once it is created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll raise a PR to fix that then and change to use additionalSettings here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've opened #52602 to cleanup the name to avoid this situation.
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 elastic#56427 and elastic#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 elastic#56427 (comment) for the full argumentation). This change introduces a system property that effectively bypasses the configuration value of xpack.security.ssl.diagnose.trust and disables the diagnostic trust manager. We will then set this system property in our periodic CI jobs for Java 8.
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 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 elastic#56427 and elastic#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 elastic#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 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 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 elastic#56427 and elastic#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 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 change aims to fix our setup in CI so that we can run 7.7 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 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 touches many of our tests but the changes are actually
few. Setting xpack.security.ssl.diagnose.trust to true
wraps SunJSSE TrustManager with our own DiagnosticTrustManager and
this is not allowed when SunJSSE is in FIPS mode. So when we
use SunJSSE in FIPS mode ( currently only when running our tests
with FIPS mode on for Java 8 runtime ), we need to make sure that
the Diagnostic TrustManager is not enabled. This change
ensures that whenever a new SSLService is to be created, we
explicitly pass xpack.security.ssl.diagnose.trust=false in the
settings used for the SSLService, when we run in FIPS mode in
Java 8.