Skip to content

Commit 66edba2

Browse files
jkakavasalbertzaharovits
authored andcommitted
[TEST] Allow to run in FIPS JVM (#32607)
* Change SecurityNioHttpServerTransportTests to use PEM key and certificate files instead of a JKS keystore so that this tests can also run in a FIPS 140 JVM * Do not attempt to run cases with ssl.verification_mode NONE in SessionFactoryTests so that the tests can run in a FIPS 140 JVM
1 parent ceb1ae4 commit 66edba2

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactoryTests.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,13 @@ public void testConnectionFactoryReturnsCorrectLDAPConnectionOptions() throws Ex
9393
options = SessionFactory.connectionOptions(realmConfig, sslService.apply(settings), logger);
9494
assertThat(options.getSSLSocketVerifier(), is(instanceOf(TrustAllSSLSocketVerifier.class)));
9595

96-
settings = Settings.builder().put("ssl.verification_mode", VerificationMode.NONE).build();
97-
realmConfig = new RealmConfig(realmName, settings, environment.settings(), environment, threadContext);
98-
options = SessionFactory.connectionOptions(realmConfig, sslService.apply(settings), logger);
99-
assertThat(options.getSSLSocketVerifier(), is(instanceOf(TrustAllSSLSocketVerifier.class)));
96+
// Can't run in FIPS with verification_mode none, disable this check instead of duplicating the test case
97+
if (inFipsJvm() == false) {
98+
settings = Settings.builder().put("ssl.verification_mode", VerificationMode.NONE).build();
99+
realmConfig = new RealmConfig(realmName, settings, environment.settings(), environment, threadContext);
100+
options = SessionFactory.connectionOptions(realmConfig, sslService.apply(settings), logger);
101+
assertThat(options.getSSLSocketVerifier(), is(instanceOf(TrustAllSSLSocketVerifier.class)));
102+
}
100103

101104
settings = Settings.builder().put("ssl.verification_mode", VerificationMode.FULL).build();
102105
realmConfig = new RealmConfig(realmName, settings, environment.settings(), environment, threadContext);

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/nio/SecurityNioHttpServerTransportTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,13 @@ public class SecurityNioHttpServerTransportTests extends ESTestCase {
4949

5050
@Before
5151
public void createSSLService() {
52-
Path testNodeStore = getDataPath("/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks");
52+
Path testNodeKey = getDataPath("/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.pem");
53+
Path testNodeCert = getDataPath("/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.crt");
5354
MockSecureSettings secureSettings = new MockSecureSettings();
54-
secureSettings.setString("xpack.ssl.keystore.secure_password", "testnode");
55+
secureSettings.setString("xpack.ssl.secure_key_passphrase", "testnode");
5556
Settings settings = Settings.builder()
56-
.put("xpack.ssl.keystore.path", testNodeStore)
57+
.put("xpack.ssl.key", testNodeKey)
58+
.put("xpack.ssl.certificate", testNodeCert)
5759
.put("path.home", createTempDir())
5860
.setSecureSettings(secureSettings)
5961
.build();

0 commit comments

Comments
 (0)