-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Enable tests in FIPS 140 in JDK 11 #48378
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
Changes from 6 commits
0b98221
f5651a2
65f7532
cc1c5fe
1a864a7
74b0548
6b30693
4b17e9a
85e3cf3
80a28ee
3543a4b
4b48f7f
403abd3
a3db46d
b44534f
66d1a99
e4f59f0
d6ea75a
99aeb03
f1cf5b9
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 |
---|---|---|
|
@@ -34,6 +34,7 @@ | |
import org.gradle.api.Named; | ||
import org.gradle.api.NamedDomainObjectContainer; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.artifacts.Configuration; | ||
import org.gradle.api.logging.Logger; | ||
import org.gradle.api.logging.Logging; | ||
import org.gradle.api.tasks.Classpath; | ||
|
@@ -70,6 +71,7 @@ | |
import java.util.LinkedHashMap; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.Locale; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
|
@@ -454,6 +456,10 @@ public synchronized void start() { | |
|
||
copyExtraConfigFiles(); | ||
|
||
copyExtraJars(); | ||
|
||
configureNodeForFips(); | ||
|
||
if (isSettingTrue("xpack.security.enabled")) { | ||
if (credentials.isEmpty()) { | ||
user(Collections.emptyMap()); | ||
|
@@ -530,6 +536,40 @@ private void copyExtraConfigFiles() { | |
}); | ||
} | ||
|
||
/** | ||
* Copies extra jars to the `/lib` directory. | ||
* //TODO: Remove this when system modules are available | ||
*/ | ||
private void copyExtraJars() { | ||
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. We prefer not to couple testclusters with random project configuration like an A more generic way would be to add the possibility to add hooks right before the task starts. 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. I moved this outside as suggested, similar to how extraConfigurationFiles work |
||
Configuration extraJarsConfig = project.getConfigurations().findByName("extraJars"); | ||
if ( extraJarsConfig != null ) { | ||
Set<File> extraJars = project.getConfigurations().getByName("extraJars").getFiles(); | ||
for (File jar : extraJars) { | ||
Path destination = getDistroDir().resolve("lib"); | ||
LOGGER.info("Adding extra jar {} to {}", jar.getName(), destination); | ||
project.copy(spec -> { | ||
spec.from(jar); | ||
spec.into(destination); | ||
}); | ||
} | ||
} | ||
} | ||
|
||
private void configureNodeForFips() { | ||
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. We should do this externally, you can use 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. I can't figure out how I can reference the file locations from within 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. Locations of what files exactly? 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. The fips_java.security, fips_java.policy and cacerts.bcfks that I copy as extra config files 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. That's problematic indeed. Does this needs to be an absolute path ? Would a path relative to cwd work ? e.x. 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. These paths are passed as values to system properties, not used in ES configuration so we either need an absolute path. Maybe we have a global reference to the ES_CONF_DIR that can be resolved in a system property? I'll look into it 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. Solution required adding |
||
boolean inFipsJvm = Boolean.parseBoolean(System.getProperty("tests.fips.enabled", "false")); | ||
if (inFipsJvm) { | ||
systemProperties.put("java.security.properties", | ||
String.format(Locale.ROOT, "=%s/fips_java.security", getConfigDir().toString())); | ||
systemProperties.put("java.security.policy", | ||
String.format(Locale.ROOT, "=%s/fips_java.policy", getConfigDir().toString())); | ||
systemProperties.put("javax.net.ssl.trustStore", | ||
String.format(Locale.ROOT, "%s/cacerts.bcfks", getConfigDir().toString())); | ||
systemProperties.put("javax.net.ssl.trustStorePassword", "password"); | ||
systemProperties.put("javax.net.ssl.keyStorePassword", "password"); | ||
systemProperties.put("javax.net.ssl.trustStoreType","BCFKS"); | ||
} | ||
} | ||
|
||
private void installModules() { | ||
if (testDistribution == TestDistribution.INTEG_TEST) { | ||
logToProcessStdout("Installing " + modules.size() + "modules"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
grant { | ||
permission java.security.SecurityPermission "putProviderProperty.BCFIPS"; | ||
permission java.security.SecurityPermission "putProviderProperty.BCJSSE"; | ||
permission java.lang.RuntimePermission "getProtectionDomain"; | ||
permission java.util.PropertyPermission "java.runtime.name", "read"; | ||
permission org.bouncycastle.crypto.CryptoServicesPermission "tlsAlgorithmsEnabled"; | ||
//io.netty.handler.codec.DecoderException | ||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.internal.spec"; | ||
//java.security.InvalidAlgorithmParameterException: Cannot process GCMParameterSpec | ||
permission java.lang.RuntimePermission "accessDeclaredMembers"; | ||
permission java.util.PropertyPermission "intellij.debug.agent", "read"; | ||
permission java.util.PropertyPermission "intellij.debug.agent", "write"; | ||
permission org.bouncycastle.crypto.CryptoServicesPermission "exportSecretKey"; | ||
permission org.bouncycastle.crypto.CryptoServicesPermission "exportPrivateKey"; | ||
permission java.io.FilePermission "${javax.net.ssl.trustStore}", "read"; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
security.provider.1=org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider | ||
security.provider.2=org.bouncycastle.jsse.provider.BouncyCastleJsseProvider fips:BCFIPS | ||
security.provider.3=SUN | ||
securerandom.source=file:/dev/urandom | ||
securerandom.strongAlgorithms=NativePRNGBlocking:SUN,DRBG:SUN | ||
securerandom.drbg.config= | ||
login.configuration.provider=sun.security.provider.ConfigFile | ||
policy.provider=sun.security.provider.PolicyFile | ||
policy.expandProperties=true | ||
policy.allowSystemProperty=true | ||
policy.ignoreIdentityScope=false | ||
keystore.type=BCFKS | ||
keystore.type.compat=true | ||
package.access=sun.misc.,\ | ||
sun.reflect. | ||
package.definition=sun.misc.,\ | ||
sun.reflect. | ||
security.overridePropertiesFile=true | ||
ssl.KeyManagerFactory.algorithm=PKIX | ||
ssl.TrustManagerFactory.algorithm=PKIX | ||
networkaddress.cache.negative.ttl=10 | ||
krb5.kdc.bad.policy = tryLast | ||
jdk.certpath.disabledAlgorithms=MD2, MD5, SHA1 jdkCA & usage TLSServer, \ | ||
RSA keySize < 1024, DSA keySize < 1024, EC keySize < 224 | ||
jdk.jar.disabledAlgorithms=MD2, MD5, RSA keySize < 1024, \ | ||
DSA keySize < 1024 | ||
jdk.tls.disabledAlgorithms=SSLv3, RC4, MD5withRSA, DH keySize < 1024, \ | ||
EC keySize < 224, DES40_CBC, RC4_40, 3DES_EDE_CBC | ||
jdk.tls.legacyAlgorithms= \ | ||
K_NULL, C_NULL, M_NULL, \ | ||
DH_anon, ECDH_anon, \ | ||
RC4_128, RC4_40, DES_CBC, DES40_CBC, \ | ||
3DES_EDE_CBC | ||
jdk.tls.keyLimits=AES/GCM/NoPadding KeyUpdate 2^37 | ||
crypto.policy=unlimited | ||
jdk.xml.dsig.secureValidationPolicy=\ | ||
disallowAlg http://www.w3.org/TR/1999/REC-xslt-19991116,\ | ||
disallowAlg http://www.w3.org/2001/04/xmldsig-more#rsa-md5,\ | ||
disallowAlg http://www.w3.org/2001/04/xmldsig-more#hmac-md5,\ | ||
disallowAlg http://www.w3.org/2001/04/xmldsig-more#md5,\ | ||
maxTransforms 5,\ | ||
maxReferences 30,\ | ||
disallowReferenceUriSchemes file http https,\ | ||
minKeySize RSA 1024,\ | ||
minKeySize DSA 1024,\ | ||
minKeySize EC 224,\ | ||
noDuplicateIds,\ | ||
noRetrievalMethodLoops | ||
jceks.key.serialFilter = java.base/java.lang.Enum;java.base/java.security.KeyRep;\ | ||
java.base/java.security.KeyRep$Type;java.base/javax.crypto.spec.SecretKeySpec;!* |
Uh oh!
There was an error while loading. Please reload this page.