|
@@ -26,7 +26,6 @@ import org.junit.Before;
|
|
|
|
|
|
import javax.net.ssl.SSLContext;
|
|
|
import javax.net.ssl.SSLHandshakeException;
|
|
|
-
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.io.OutputStream;
|
|
@@ -263,7 +262,7 @@ public class SSLConfigurationReloaderTests extends ESTestCase {
|
|
|
try (MockWebServer server = getSslServer(serverKeyPath, serverCertPath, "testnode")) {
|
|
|
final Consumer<SSLContext> trustMaterialPreChecks = (context) -> {
|
|
|
try (CloseableHttpClient client = HttpClients.custom().setSSLContext(context).build()) {
|
|
|
- privilegedConnect(() -> client.execute(new HttpGet("https://localhost:" + server.getPort())).close());
|
|
|
+ privilegedConnect(() -> client.execute(new HttpGet("https://localhost:" + server.getPort())));//.close());
|
|
|
} catch (Exception e) {
|
|
|
throw new RuntimeException("Exception connecting to the mock server", e);
|
|
|
}
|
|
@@ -480,7 +479,9 @@ public class SSLConfigurationReloaderTests extends ESTestCase {
|
|
|
try (InputStream is = Files.newInputStream(keyStorePath)) {
|
|
|
keyStore.load(is, keyStorePass.toCharArray());
|
|
|
}
|
|
|
- final SSLContext sslContext = new SSLContextBuilder().loadKeyMaterial(keyStore, keyStorePass.toCharArray())
|
|
|
+ final SSLContext sslContext = new SSLContextBuilder()
|
|
|
+ .loadKeyMaterial(keyStore, keyStorePass.toCharArray())
|
|
|
+ .setProtocol("TLSv1.2")
|
|
|
.build();
|
|
|
MockWebServer server = new MockWebServer(sslContext, false);
|
|
|
server.enqueue(new MockResponse().setResponseCode(200).setBody("body"));
|
|
@@ -494,7 +495,9 @@ public class SSLConfigurationReloaderTests extends ESTestCase {
|
|
|
keyStore.load(null, password.toCharArray());
|
|
|
keyStore.setKeyEntry("testnode_ec", PemUtils.readPrivateKey(keyPath, password::toCharArray), password.toCharArray(),
|
|
|
CertParsingUtils.readCertificates(Collections.singletonList(certPath)));
|
|
|
- final SSLContext sslContext = new SSLContextBuilder().loadKeyMaterial(keyStore, password.toCharArray())
|
|
|
+ final SSLContext sslContext = new SSLContextBuilder()
|
|
|
+ .loadKeyMaterial(keyStore, password.toCharArray())
|
|
|
+ .setProtocol("TLSv1.2")
|
|
|
.build();
|
|
|
MockWebServer server = new MockWebServer(sslContext, false);
|
|
|
server.enqueue(new MockResponse().setResponseCode(200).setBody("body"));
|
|
@@ -509,7 +512,10 @@ public class SSLConfigurationReloaderTests extends ESTestCase {
|
|
|
try (InputStream is = Files.newInputStream(trustStorePath)) {
|
|
|
trustStore.load(is, trustStorePass.toCharArray());
|
|
|
}
|
|
|
- final SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(trustStore, null).build();
|
|
|
+ final SSLContext sslContext = new SSLContextBuilder()
|
|
|
+ .loadTrustMaterial(trustStore, null)
|
|
|
+ .setProtocol("TLSv1.2")
|
|
|
+ .build();
|
|
|
return HttpClients.custom().setSSLContext(sslContext).build();
|
|
|
}
|
|
|
|
|
@@ -526,7 +532,10 @@ public class SSLConfigurationReloaderTests extends ESTestCase {
|
|
|
for (Certificate cert : CertParsingUtils.readCertificates(trustedCertificatePaths)) {
|
|
|
trustStore.setCertificateEntry(cert.toString(), cert);
|
|
|
}
|
|
|
- final SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(trustStore, null).build();
|
|
|
+ final SSLContext sslContext = new SSLContextBuilder()
|
|
|
+ .loadTrustMaterial(trustStore, null)
|
|
|
+ .setProtocol("TLSv1.2")
|
|
|
+ .build();
|
|
|
return HttpClients.custom().setSSLContext(sslContext).build();
|
|
|
}
|
|
|
|