-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
71c7534
commit e9af78c
Showing
11 changed files
with
281 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
.../src/main/java/org/elasticsearch/test/cluster/local/FipsEnabledClusterConfigProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.test.cluster.local; | ||
|
||
import org.elasticsearch.test.cluster.util.resource.Resource; | ||
|
||
public class FipsEnabledClusterConfigProvider implements LocalClusterConfigProvider { | ||
|
||
@Override | ||
public void apply(LocalClusterSpecBuilder builder) { | ||
if (isFipsEnabled()) { | ||
builder.configFile( | ||
"fips_java.security", | ||
Resource.fromClasspath(isOracleJvm() ? "fips/fips_java_oracle.security" : "fips/fips_java.security") | ||
) | ||
.configFile("fips_java.policy", Resource.fromClasspath("fips/fips_java.policy")) | ||
.configFile("cacerts.bcfks", Resource.fromClasspath("fips/cacerts.bcfks")) | ||
.systemProperty("java.security.properties", "=${ES_PATH_CONF}/fips_java.security") | ||
.systemProperty("java.security.policy", "=${ES_PATH_CONF}/fips_java.policy") | ||
.systemProperty("javax.net.ssl.trustStore", "${ES_PATH_CONF}/cacerts.bcfks") | ||
.systemProperty("javax.net.ssl.trustStorePassword", "password") | ||
.systemProperty("javax.net.ssl.keyStorePassword", "password") | ||
.systemProperty("javax.net.ssl.keyStoreType", "BCFKS") | ||
.systemProperty("org.bouncycastle.fips.approved_only", "true") | ||
.setting("network.host", "_local:ipv4_") | ||
.setting("xpack.security.enabled", "false") | ||
.setting("xpack.security.fips_mode.enabled", "true") | ||
.setting("xpack.license.self_generated.type", "trial") | ||
.setting("xpack.security.authc.password_hashing.algorithm", "pbkdf2_stretch") | ||
.keystorePassword("keystore-password"); | ||
} | ||
} | ||
|
||
private static boolean isFipsEnabled() { | ||
return Boolean.getBoolean("tests.fips.enabled"); | ||
} | ||
|
||
private static boolean isOracleJvm() { | ||
return System.getProperty("java.vendor").toLowerCase().contains("oracle"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
16 changes: 16 additions & 0 deletions
16
test/test-clusters/src/main/resources/fips/fips_java.policy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
}; |
51 changes: 51 additions & 0 deletions
51
test/test-clusters/src/main/resources/fips/fips_java.security
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
security.provider.1=org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider C:HYBRID;ENABLE{All}; | ||
security.provider.2=org.bouncycastle.jsse.provider.BouncyCastleJsseProvider fips:BCFIPS | ||
security.provider.3=SUN | ||
security.provider.4=SunJGSS | ||
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;!* |
Oops, something went wrong.