Explicit allow to enable / disable session cache
Motivation: It is sometimes useful to enable / disable the session cache. Modifications: * Add OpenSslSessionContext.setSessionCacheEnabled(...) and isSessionCacheEnabled() Result: It is now possible to enable / disable cache on the fly
This commit is contained in:
parent
8a1c7f2ca6
commit
8e6739ddc0
@ -214,5 +214,15 @@ public final class OpenSslClientContext extends OpenSslContext {
|
||||
public int getSessionCacheSize() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSessionCacheEnabled(boolean enabled) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSessionCacheEnabled() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -319,5 +319,16 @@ public final class OpenSslServerContext extends OpenSslContext {
|
||||
public int getSessionCacheSize() {
|
||||
return (int) SSLContext.getSessionCacheSize(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSessionCacheEnabled(boolean enabled) {
|
||||
long mode = enabled ? SSL.SSL_SESS_CACHE_SERVER : SSL.SSL_SESS_CACHE_OFF;
|
||||
SSLContext.setSessionCacheMode(context, mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSessionCacheEnabled() {
|
||||
return SSLContext.getSessionCacheMode(context) == SSL.SSL_SESS_CACHE_SERVER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,16 @@ public abstract class OpenSslSessionContext implements SSLSessionContext {
|
||||
SSLContext.setSessionTicketKeys(context, keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable caching of SSL sessions.
|
||||
*/
|
||||
public abstract void setSessionCacheEnabled(boolean enabled);
|
||||
|
||||
/**
|
||||
* Return {@code true} if caching of SSL sessions is enabled, {@code false} otherwise.
|
||||
*/
|
||||
public abstract boolean isSessionCacheEnabled();
|
||||
|
||||
/**
|
||||
* Returns the stats of this context.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user