use of com.android.org.conscrypt.SSLClientSessionCache in project android_frameworks_base by AOSPA.
the class SSLSessionCacheTest method testInstall_compatibleContext.
public void testInstall_compatibleContext() throws Exception {
final SSLContext ctx = SSLContext.getDefault();
final SSLClientSessionCache mock = LittleMock.mock(SSLClientSessionCache.class);
final ClientSessionContext clientCtx = (ClientSessionContext) ctx.getClientSessionContext();
try {
SSLSessionCache.install(new SSLSessionCache(mock), ctx);
clientCtx.getSession("www.foogle.com", 443);
LittleMock.verify(mock).getSessionData(LittleMock.anyString(), LittleMock.anyInt());
} finally {
// Restore cacheless behaviour.
SSLSessionCache.install(null, ctx);
clientCtx.getSession("www.foogle.com", 443);
LittleMock.verifyNoMoreInteractions(mock);
}
}
use of com.android.org.conscrypt.SSLClientSessionCache in project platform_frameworks_base by android.
the class SSLSessionCacheTest method testInstall_compatibleContext.
public void testInstall_compatibleContext() throws Exception {
final SSLContext ctx = SSLContext.getDefault();
final SSLClientSessionCache mock = Mockito.mock(SSLClientSessionCache.class);
final ClientSessionContext clientCtx = (ClientSessionContext) ctx.getClientSessionContext();
try {
SSLSessionCache.install(new SSLSessionCache(mock), ctx);
clientCtx.getSession("www.foogle.com", 443);
Mockito.verify(mock).getSessionData(Mockito.anyString(), Mockito.anyInt());
} finally {
// Restore cacheless behaviour.
SSLSessionCache.install(null, ctx);
clientCtx.getSession("www.foogle.com", 443);
Mockito.verifyNoMoreInteractions(mock);
}
}
use of com.android.org.conscrypt.SSLClientSessionCache in project android_frameworks_base by DirtyUnicorns.
the class SSLSessionCacheTest method testInstall_compatibleContext.
public void testInstall_compatibleContext() throws Exception {
final SSLContext ctx = SSLContext.getDefault();
final SSLClientSessionCache mock = LittleMock.mock(SSLClientSessionCache.class);
final ClientSessionContext clientCtx = (ClientSessionContext) ctx.getClientSessionContext();
try {
SSLSessionCache.install(new SSLSessionCache(mock), ctx);
clientCtx.getSession("www.foogle.com", 443);
LittleMock.verify(mock).getSessionData(LittleMock.anyString(), LittleMock.anyInt());
} finally {
// Restore cacheless behaviour.
SSLSessionCache.install(null, ctx);
clientCtx.getSession("www.foogle.com", 443);
LittleMock.verifyNoMoreInteractions(mock);
}
}
use of com.android.org.conscrypt.SSLClientSessionCache in project android_frameworks_base by ResurrectionRemix.
the class SSLSessionCacheTest method testInstall_compatibleContext.
public void testInstall_compatibleContext() throws Exception {
final SSLContext ctx = SSLContext.getDefault();
final SSLClientSessionCache mock = LittleMock.mock(SSLClientSessionCache.class);
final ClientSessionContext clientCtx = (ClientSessionContext) ctx.getClientSessionContext();
try {
SSLSessionCache.install(new SSLSessionCache(mock), ctx);
clientCtx.getSession("www.foogle.com", 443);
LittleMock.verify(mock).getSessionData(LittleMock.anyString(), LittleMock.anyInt());
} finally {
// Restore cacheless behaviour.
SSLSessionCache.install(null, ctx);
clientCtx.getSession("www.foogle.com", 443);
LittleMock.verifyNoMoreInteractions(mock);
}
}
use of com.android.org.conscrypt.SSLClientSessionCache in project platform_external_apache-http by android.
the class SSLConnectionClosedByUserException method initializeEngine.
/**
* @param sessionDir directory to cache SSL sessions
*/
public static void initializeEngine(File sessionDir) {
try {
SSLClientSessionCache cache = null;
if (sessionDir != null) {
Log.d("HttpsConnection", "Caching SSL sessions in " + sessionDir + ".");
cache = FileClientSessionCache.usingDirectory(sessionDir);
}
OpenSSLContextImpl sslContext = (OpenSSLContextImpl) Conscrypt.newPreferredSSLContextSpi();
// here, trust managers is a single trust-all manager
TrustManager[] trustManagers = new TrustManager[] { new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(X509Certificate[] certs, String authType) {
}
} };
sslContext.engineInit(null, trustManagers, null);
sslContext.engineGetClientSessionContext().setPersistentCache(cache);
synchronized (HttpsConnection.class) {
mSslSocketFactory = sslContext.engineGetSocketFactory();
}
} catch (KeyManagementException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Aggregations