-
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 #56526
Changes from all commits
091d425
c3c7af6
58539f9
ba92aeb
24a5306
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,7 @@ | |
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
import static org.elasticsearch.test.TestMatchers.throwableWithMessage; | ||
import static org.elasticsearch.xpack.core.ssl.SSLService.inSunJsseInFipsMode; | ||
import static org.hamcrest.Matchers.arrayContainingInAnyOrder; | ||
import static org.hamcrest.Matchers.contains; | ||
import static org.hamcrest.Matchers.containsString; | ||
|
@@ -90,14 +91,19 @@ public class SSLServiceTests extends ESTestCase { | |
|
||
@Before | ||
public void setup() throws Exception { | ||
// Randomise the keystore type (jks/PKCS#12) | ||
if (randomBoolean()) { | ||
testnodeStore = getDataPath("/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks"); | ||
// The default is to use JKS. Randomly test with explicit and with the default value. | ||
testnodeStoreType = "jks"; | ||
} else { | ||
// Randomise the keystore type (jks/PKCS#12) when possible | ||
if (inFipsJvm()) { | ||
testnodeStore = getDataPath("/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.p12"); | ||
testnodeStoreType = randomBoolean() ? "PKCS12" : null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, it shouldn't make a difference as we should be able to auto detect. Arguably we don't need to test this here, but I believe it was originally there too and I didn't introduce this in this change |
||
} else { | ||
if (randomBoolean()) { | ||
testnodeStore = getDataPath("/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks"); | ||
// The default is to use JKS. Randomly test with explicit and with the default value. | ||
testnodeStoreType = "jks"; | ||
} else { | ||
testnodeStore = getDataPath("/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.p12"); | ||
testnodeStoreType = randomBoolean() ? "PKCS12" : null; | ||
} | ||
} | ||
logger.info("Using [{}] key/truststore [{}]", testnodeStoreType, testnodeStore); | ||
testnodeCert = getDataPath("/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.crt"); | ||
|
@@ -820,6 +826,7 @@ public void testThatSSLIOSessionStrategyTrustsJDKTrustedCAs() throws Exception { | |
} | ||
|
||
public void testWrapTrustManagerWhenDiagnosticsEnabled() { | ||
assumeFalse("We explicitly disable diagnostic trust manager in SunJSSE in FIPS mode ", inSunJsseInFipsMode()); | ||
final Settings.Builder builder = Settings.builder(); | ||
if (randomBoolean()) { // randomly select between default, and explicit enabled | ||
builder.put("xpack.security.ssl.diagnose.trust", true); | ||
|
@@ -841,7 +848,7 @@ public void testDontWrapTrustManagerWhenDiagnosticsDisabled() { | |
assertThat(sslService.wrapWithDiagnostics(baseTrustManager, sslConfiguration), sameInstance(baseTrustManager)); | ||
} | ||
|
||
public void testDontWrapTrustManagerByDefaultWhenInFips(){ | ||
public void testDontWrapTrustManagerByDefaultWhenInFips() { | ||
final Settings.Builder builder = Settings.builder(); | ||
builder.put("xpack.security.fips_mode.enabled", true); | ||
final SSLService sslService = new SSLService(builder.build(), env); | ||
|
@@ -850,7 +857,8 @@ public void testDontWrapTrustManagerByDefaultWhenInFips(){ | |
assertThat(sslService.wrapWithDiagnostics(baseTrustManager, sslConfiguration), sameInstance(baseTrustManager)); | ||
} | ||
|
||
public void testWrapTrustManagerWhenInFipsAndExplicitlyConfigured(){ | ||
public void testWrapTrustManagerWhenInFipsAndExplicitlyConfigured() { | ||
assumeFalse("We explicitly disable diagnostic trust manager in SunJSSE in FIPS mode ", inSunJsseInFipsMode()); | ||
final Settings.Builder builder = Settings.builder(); | ||
builder.put("xpack.security.fips_mode.enabled", true); | ||
builder.put("xpack.security.ssl.diagnose.trust", true); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
import org.elasticsearch.test.ESIntegTestCase.ClusterScope; | ||
import org.elasticsearch.test.InternalTestCluster.RestartCallback; | ||
import org.elasticsearch.test.SecurityIntegTestCase; | ||
import org.junit.BeforeClass; | ||
|
||
import java.io.IOException; | ||
import java.io.UncheckedIOException; | ||
|
@@ -28,6 +29,11 @@ | |
@ClusterScope(transportClientRatio = 0) | ||
public class SSLReloadDuringStartupIntegTests extends SecurityIntegTestCase { | ||
|
||
@BeforeClass | ||
public static void skipInFips() { | ||
assumeFalse("Can't use JKS keystores in FIPS JVM", inFipsJvm()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to make this work if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe? But we don't support PKCS12 nor JKS stores in FIPS mode so there is not much value in testing reloading such a keystore. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right. Forgot about this again. |
||
} | ||
|
||
@Override | ||
public Settings nodeSettings(int nodeOrdinal) { | ||
Settings settings = super.nodeSettings(nodeOrdinal); | ||
|
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.
What does the prefixed
=
do here? I wasn't able to find documentation on that special syntax. We should add a comment explaining for future readers.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 explain this here
elasticsearch/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy
Line 165 in 1fe5264