Update protocol for MemcachedCache (#16035)

This commit is contained in:
Parth Agrawal 2024-03-07 11:58:11 +05:30 committed by GitHub
parent 564c44ed85
commit bf39c71d2a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View File

@ -413,7 +413,7 @@ public class MemcachedCache implements Cache
// Build SSLContext // Build SSLContext
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init((KeyStore) null); tmf.init((KeyStore) null);
SSLContext sslContext = SSLContext.getInstance("TLS"); SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
sslContext.init(null, tmf.getTrustManagers(), null); sslContext.init(null, tmf.getTrustManagers(), null);
// Create the client in TLS mode // Create the client in TLS mode
connectionFactoryBuilder.setSSLContext(sslContext); connectionFactoryBuilder.setSSLContext(sslContext);

View File

@ -254,6 +254,8 @@ public class MemcachedCacheTest
Assert.assertEquals(connectionFactoryDynamic.getClientMode(), ClientMode.Dynamic); Assert.assertEquals(connectionFactoryDynamic.getClientMode(), ClientMode.Dynamic);
//enableTls is true so sslContext is not null //enableTls is true so sslContext is not null
Assert.assertNotNull(connectionFactoryDynamic.getSSLContext()); Assert.assertNotNull(connectionFactoryDynamic.getSSLContext());
// Ensure Protocol is TLSv1.2
Assert.assertEquals("TLSv1.2", connectionFactoryDynamic.getSSLContext().getProtocol());
} }
@Test @Test