Skip to content

Commit d9f5e4f

Browse files
committed
Pin TLS1.2 in SSLConfigurationReloaderTests
Ensure that the SSLConfigurationReloaderTests can run with JDK 11 by pinning the HttpClient to TLS version to TLS1.2. This is necessary becase even if the MockWebServer is set to user TLS1.2, we don't set its enabled protocols, so if it receives a TLS1.3 request (which is the default behavior for HttpClient in JDK11), it will use TLS1.3 and the original issue will manifest again. Relates #33127 Resolves #32124
1 parent 3919133 commit d9f5e4f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ssl/SSLConfigurationReloaderTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ private static CloseableHttpClient getSSLClient(Path trustStorePath, String trus
510510
try (InputStream is = Files.newInputStream(trustStorePath)) {
511511
trustStore.load(is, trustStorePass.toCharArray());
512512
}
513-
final SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(trustStore, null).build();
513+
final SSLContext sslContext = new SSLContextBuilder().useProtocol("TLSv1.2").loadTrustMaterial(trustStore, null).build();
514514
return HttpClients.custom().setSSLContext(sslContext).build();
515515
}
516516

@@ -527,7 +527,7 @@ private static CloseableHttpClient getSSLClient(List<Path> trustedCertificatePat
527527
for (Certificate cert : CertParsingUtils.readCertificates(trustedCertificatePaths)) {
528528
trustStore.setCertificateEntry(cert.toString(), cert);
529529
}
530-
final SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(trustStore, null).build();
530+
final SSLContext sslContext = new SSLContextBuilder().useProtocol("TLSv1.2").loadTrustMaterial(trustStore, null).build();
531531
return HttpClients.custom().setSSLContext(sslContext).build();
532532
}
533533

0 commit comments

Comments
 (0)