Skip to content
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

fix and unmute FIPS tests #119618

Merged
merged 11 commits into from
Jan 8, 2025
Merged

Conversation

jakelandis
Copy link
Contributor

@jakelandis jakelandis commented Jan 6, 2025

Fixes and un-mutes tests associated with FIPS.
Most of the fixes are due to differing expected exceptions or log messages when using BouncyCastle as the JCE/JSSE provider.
Only test code is changed with this commit.

fixes: #49094

setting 'xpack.monitoring.exporters._http.auth.username', 'monitoring_agent'
setting 'xpack.monitoring.exporters._http.ssl.verification_mode', 'full'
setting 'xpack.monitoring.exporters._http.ssl.certificate_authorities', 'testnode.crt'
keystore 'xpack.monitoring.exporters._http.auth.secure_password', 'x-pack-test-password'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test has been muted for 5+ years... I believe that this is needed due to the changes in secure settings and stricter validation. Should be functionally equivalent.


@BeforeClass
public static void getKeyStore() {
try {
keyStore = PathUtils.get(SmokeTestMonitoringWithSecurityIT.class.getResource("/testnode.jks").toURI());
trustStore = PathUtils.get(SmokeTestMonitoringWithSecurityIT.class.getResource("/testnode.crt").toURI());
Copy link
Contributor Author

@jakelandis jakelandis Jan 6, 2025

Choose a reason for hiding this comment

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

to enable this to work in FIPS, I need to prefer to use PEM formatting not the java keystore. also fixed the name to call this a trust store, not a key store (so no pass needed).

public void testSettingsFilter() throws IOException {
final Request request = new Request("GET", "/_cluster/settings");
final Response response = client().performRequest(request);
final ObjectPath path = ObjectPath.createFromResponse(response);
final Map<String, Object> settings = path.evaluate("transient.xpack.monitoring.exporters._http");
final Map<String, Object> settings = path.evaluate("persistent.xpack.monitoring.exporters._http");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this was just an oversite when removing the HLRC

assertThat(handshakeException, throwableWithMessage(containsStringIgnoringCase("subject alternative names")));
assertThat(handshakeException, throwableWithMessage(containsString(webServer.getHostName())));

final Exception handshakeException = expectThrows(Exception.class, () -> clientSocket.getInputStream().read());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bouncy castle throws a different exception with a different stack trace.

@@ -133,7 +132,7 @@ public void testDiagnosticTrustManagerForHostnameVerificationFailure() throws Ex
DiagnosticTrustManager.class.getName(),
Level.WARN,
"failed to establish trust with server at \\["
+ Pattern.quote(webServer.getHostName())
+ (inFipsJvm() ? "<unknown host>" : Pattern.quote(webServer.getHostName()))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

BC JSSE says "unknown host" but JVM's default JSSE says "127.0.0.1"

@jakelandis jakelandis added :Security/Security Security issues without another label :Security/FIPS Running ES in FIPS 140-2 mode labels Jan 6, 2025
@jakelandis jakelandis added the Team:Security Meta label for security team label Jan 7, 2025
@jakelandis
Copy link
Contributor Author

@elasticsearchmachine run elasticsearch-ci/part-1-fips

@jakelandis jakelandis added the >test Issues or PRs that are addressing/adding tests label Jan 7, 2025
@jakelandis jakelandis marked this pull request as ready for review January 7, 2025 22:00
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-security (Team:Security)

@jakelandis jakelandis added auto-backport Automatically create backport pull requests when merged v8.18.0 labels Jan 7, 2025
@slobodanadamovic slobodanadamovic self-requested a review January 7, 2025 22:42
Copy link
Contributor

@slobodanadamovic slobodanadamovic left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Thanks for fixing this!

@jakelandis jakelandis merged commit c3e11a7 into elastic:main Jan 8, 2025
21 checks passed
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
8.x

jakelandis added a commit to jakelandis/elasticsearch that referenced this pull request Jan 8, 2025
Fixes and un-mutes tests associated with FIPS.
Most of the fixes are due to differing expected exceptions or log messages when using BouncyCastle as the JCE/JSSE provider.
Only test code is changed with this commit.

fixes: elastic#49094
elasticsearchmachine pushed a commit that referenced this pull request Jan 8, 2025
Fixes and un-mutes tests associated with FIPS.
Most of the fixes are due to differing expected exceptions or log messages when using BouncyCastle as the JCE/JSSE provider.
Only test code is changed with this commit.

fixes: #49094
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged :Security/FIPS Running ES in FIPS 140-2 mode :Security/Security Security issues without another label Team:Security Meta label for security team >test Issues or PRs that are addressing/adding tests v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SSL related tests failures with BCJSSE in FIPS 140 mode
3 participants