Skip to content

Enable testing in FIPS140 JVM #31666

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

Merged
merged 24 commits into from
Jul 17, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e294ff8
Replace JKS with default keystore
jkakavas Jun 12, 2018
3874a1d
Merge remote-tracking branch 'origin/master' into fips-testing
jkakavas Jun 12, 2018
5f17449
Merge remote-tracking branch 'origin/master' into fips-testing
jkakavas Jun 13, 2018
459734d
Merge remote-tracking branch 'origin/master' into fips-testing
jkakavas Jun 15, 2018
c2ba7f7
Ensure our tests can run in a FIPS JVM
jkakavas Jun 28, 2018
5e232c3
Merge remote-tracking branch 'origin/master' into fips-testing
jkakavas Jun 28, 2018
534e865
Checkstyle warnings
jkakavas Jun 29, 2018
1c66768
Address feedback
jkakavas Jun 29, 2018
5bdca0b
Merge remote-tracking branch 'origin/master' into fips-testing
jkakavas Jul 2, 2018
04911a4
Merge remote-tracking branch 'origin/master' into fips-testing
jkakavas Jul 2, 2018
e5009ea
Address feedback
jkakavas Jul 3, 2018
0d6b842
fix typo
jkakavas Jul 6, 2018
f6dfb02
Add call to countdown() for the reloadLatch
jkakavas Jul 12, 2018
20ce308
Merge remote-tracking branch 'origin/master' into fips-testing
jkakavas Jul 12, 2018
c2e3de6
address feedback
jkakavas Jul 12, 2018
e55ea07
Fix test
jkakavas Jul 12, 2018
e114e01
Remove debug prints and run precommit checks
jkakavas Jul 12, 2018
b958d2b
Ensure PrivateKey is readable(#32021)
jkakavas Jul 13, 2018
dc710f9
Fix failing test
jkakavas Jul 13, 2018
eddb426
Merge remote-tracking branch 'origin/master' into fips-testing
jkakavas Jul 13, 2018
75a73f1
Merge remote-tracking branch 'origin/master' into fips-testing
jkakavas Jul 14, 2018
89cf245
remove import
jkakavas Jul 14, 2018
ff9505e
Merge remote-tracking branch 'origin/master' into fips-testing
jkakavas Jul 16, 2018
dcac90c
Merge branch 'fips-testing' of github.com:jkakavas/elasticsearch into…
jkakavas Jul 16, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ private RestClient buildRestClient() {
private static SSLContext getSslContext() throws Exception {
SSLContext sslContext = SSLContext.getInstance("TLS");
try (InputStream certFile = RestClientBuilderIntegTests.class.getResourceAsStream("/test.crt")) {
Copy link
Member

Choose a reason for hiding this comment

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

can you add a comment that this builds a keystore programmatically so that it is keystore format independent?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, it is not entirely keystore format independent. This was changed for the same reason the tests that load a JKS keystore from disk are changed. One can't KeyManagerFactory#init() with a JKS store in a FIPS JVM. Can it be that I missed the essence of your comment ?

Copy link
Member

Choose a reason for hiding this comment

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

The main reason I want a comment is so that someone doesn’t come along and go “this is silly let’s just use a keystore”

// Build a keystore of default type programmatically since we can't use JKS keystores to
// init a KeyManagerFactory in FIPS 140 JVMs.
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null, "password".toCharArray());
CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import org.elasticsearch.transport.TcpTransport;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.rules.ExternalResource;

import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
Expand Down Expand Up @@ -87,6 +89,14 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {

private static Path keyStoreFile;

@ClassRule
public static final ExternalResource MUTE_IN_FIPS_JVM = new ExternalResource() {
@Override
protected void before() {
assumeFalse("Can't run in a FIPS JVM because none if the supported Keystore types can be used", inFipsJvm());
Copy link
Member

Choose a reason for hiding this comment

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

s/if/of

}
};

@BeforeClass
public static void setupKeyStore() throws IOException {
Path tempDir = createTempDir();
Expand All @@ -99,9 +109,6 @@ public static void setupKeyStore() throws IOException {

@Override
protected Settings nodeSettings(int nodeOrdinal) {
if (inFipsJvm()) {
return Settings.EMPTY;
}
Path resolve = logDir.resolve(Integer.toString(nodeOrdinal));
try {
Files.createDirectory(resolve);
Expand Down Expand Up @@ -137,9 +144,6 @@ protected Path nodeConfigPath(int nodeOrdinal) {
*/
@BeforeClass
public static void startHttpd() throws Exception {
if (inFipsJvm()) {
return;
}
logDir = createTempDir();
SSLContext sslContext = getSSLContext();
httpsServer = MockHttpServer.createHttps(new InetSocketAddress(InetAddress.getLoopbackAddress().getHostAddress(), 0), 0);
Expand Down Expand Up @@ -265,9 +269,6 @@ private static SSLContext getSSLContext() throws Exception {

@AfterClass
public static void stopHttpd() throws IOException {
if (inFipsJvm()) {
return;
}
for (int i = 0; i < internalCluster().size(); i++) {
// shut them all down otherwise we get spammed with connection refused exceptions
internalCluster().stopRandomDataNode();
Expand All @@ -278,7 +279,6 @@ public static void stopHttpd() throws IOException {
}

public void testJoin() throws ExecutionException, InterruptedException {
assumeFalse("Can't run in a FIPS JVM because none if the supported Keystore types can be used", inFipsJvm());
// only wait for the cluster to form
ensureClusterSizeConsistency();
// add one more node and wait for it to join
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ private void validateSSLConfigurationIsReloaded(Settings settings, Environment e
@Override
void reloadSSLContext(SSLConfiguration configuration) {
super.reloadSSLContext(configuration);
reloadLatch.countDown();
}
};
// Baseline checks
Expand Down