SSLSessionCachepublic final class SSLSessionCache extends Object File-based cache of established SSL sessions. When re-establishing a
connection to the same server, using an SSL session cache can save some time,
power, and bandwidth by skipping directly to an encrypted stream.
This is a persistent cache which can span executions of the application. |
Fields Summary |
---|
private static final String | TAG | final com.android.org.conscrypt.SSLClientSessionCache | mSessionCache |
Constructors Summary |
---|
public SSLSessionCache(Object cache)NOTE: This needs to be Object (and not SSLClientSessionCache) because apps
that build directly against the framework (and not the SDK) might not declare
a dependency on conscrypt. Javac will then has fail while resolving constructors.
mSessionCache = (SSLClientSessionCache) cache;
| public SSLSessionCache(File dir)Create a session cache using the specified directory.
Individual session entries will be files within the directory.
Multiple instances for the same directory share data internally.
mSessionCache = FileClientSessionCache.usingDirectory(dir);
| public SSLSessionCache(android.content.Context context)Create a session cache at the default location for this app.
Multiple instances share data internally.
File dir = context.getDir("sslcache", Context.MODE_PRIVATE);
SSLClientSessionCache cache = null;
try {
cache = FileClientSessionCache.usingDirectory(dir);
} catch (IOException e) {
Log.w(TAG, "Unable to create SSL session cache in " + dir, e);
}
mSessionCache = cache;
|
Methods Summary |
---|
public static void | install(android.net.SSLSessionCache cache, javax.net.ssl.SSLContext context)Installs a {@link SSLSessionCache} on a {@link SSLContext}. The cache will
be used on all socket factories created by this context (including factories
created before this call).
SSLSessionContext clientContext = context.getClientSessionContext();
if (clientContext instanceof ClientSessionContext) {
((ClientSessionContext) clientContext).setPersistentCache(
cache == null ? null : cache.mSessionCache);
} else {
throw new IllegalArgumentException("Incompatible SSLContext: " + context);
}
|
|