We were creating PemKeyConfig objects using different private keys but always using testnode.crt certificate that uses the RSA public key. The PemKeyConfig was built but we would then later fail to handle SSL connections during the TLS handshake eitherway. This became obvious in FIPS tests where the consistency checks that FIPS 140 mandates kick in and failed early becausethe private key was of different type than the public key
This commit is contained in:
parent
31a84b17ad
commit
3c7c9573b4
|
@ -70,6 +70,7 @@ public class PemKeyConfigTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testBuildKeyConfigFromPkcs8PemFilesWithPassword() throws Exception {
|
||||
assumeFalse("Can't run in a FIPS JVM, PBE KeySpec is not available", inFipsJvm());
|
||||
final Path cert = getDataPath("/certs/cert2/cert2.crt");
|
||||
final Path key = getDataPath("/certs/cert2/cert2-pkcs8.key");
|
||||
final PemKeyConfig keyConfig = new PemKeyConfig(cert, key, "c2-pass".toCharArray());
|
||||
|
|
|
@ -23,6 +23,7 @@ public class PEMKeyConfigTests extends ESTestCase {
|
|||
public static final SecureString TESTNODE_PASSWORD = new SecureString("testnode".toCharArray());
|
||||
|
||||
public void testEncryptedPkcs8RsaKey() throws Exception {
|
||||
assumeFalse("Can't run in a FIPS JVM, PBE KeySpec is not available", inFipsJvm());
|
||||
verifyKeyConfig("testnode.crt", "key_pkcs8_encrypted.pem", TESTNODE_PASSWORD);
|
||||
}
|
||||
|
||||
|
@ -31,11 +32,11 @@ public class PEMKeyConfigTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testUnencryptedPkcs8DsaKey() throws Exception {
|
||||
verifyKeyConfig("testnode.crt", "dsa_key_pkcs8_plain.pem", NO_PASSWORD);
|
||||
verifyKeyConfig("testnode_dsa.crt", "dsa_key_pkcs8_plain.pem", NO_PASSWORD);
|
||||
}
|
||||
|
||||
public void testUnencryptedPkcs8EcKey() throws Exception {
|
||||
verifyKeyConfig("testnode.crt", "ec_key_pkcs8_plain.pem", NO_PASSWORD);
|
||||
verifyKeyConfig("testnode_ec.crt", "ec_key_pkcs8_plain.pem", NO_PASSWORD);
|
||||
}
|
||||
|
||||
public void testEncryptedPkcs1RsaKey() throws Exception {
|
||||
|
|
|
@ -91,6 +91,10 @@ openssl pkcs12 -in dsa.p12 -nodes -nocerts | openssl pkcs8 -topk8 -nocrypt -outf
|
|||
----
|
||||
[source,shell]
|
||||
----
|
||||
openssl pkcs12 -in dsa.p12 -nodes -nokeys -cacerts -out testnode_dsa.crt
|
||||
----
|
||||
[source,shell]
|
||||
----
|
||||
keytool -importkeystore -srckeystore testnode.jks -destkeystore ec.p12 -deststoretype PKCS12 \
|
||||
-srcalias testnode_ec -deststorepass testnode -destkeypass testnode
|
||||
----
|
||||
|
@ -99,8 +103,10 @@ keytool -importkeystore -srckeystore testnode.jks -destkeystore ec.p12 -deststor
|
|||
openssl pkcs12 -in ec.p12 -nodes -nocerts | openssl pkcs8 -topk8 -nocrypt -outform pem \
|
||||
-out ec_key_pkcs8_plain.pem
|
||||
----
|
||||
|
||||
|
||||
[source,shell]
|
||||
----
|
||||
openssl pkcs12 -in ec.p12 -nodes -nokeys -cacerts -out testnode_ec.crt
|
||||
----
|
||||
|
||||
Create `PKCS#8` encrypted key from the encrypted `PKCS#1` encoded `testnode.pem`
|
||||
[source,shell]
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
Bag Attributes
|
||||
friendlyName: testnode_dsa
|
||||
localKeyID: 54 69 6D 65 20 31 35 38 37 35 35 38 39 34 34 36 39 38
|
||||
subject=CN = Elasticsearch Test Node
|
||||
|
||||
issuer=CN = Elasticsearch Test Node
|
||||
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDODCCAvSgAwIBAgIEIjxzajANBglghkgBZQMEAwIFADAiMSAwHgYDVQQDExdF
|
||||
bGFzdGljc2VhcmNoIFRlc3QgTm9kZTAeFw0xODA1MTcwOTQzMThaFw00NTEwMDIw
|
||||
OTQzMThaMCIxIDAeBgNVBAMTF0VsYXN0aWNzZWFyY2ggVGVzdCBOb2RlMIIBtzCC
|
||||
ASwGByqGSM44BAEwggEfAoGBAP1/U4EddRIpUt9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