JSSE: fix SSLEngine client session storage, store when WolfSSLSession error state is not fatal
parent
8449b6744e
commit
5d37d5c13d
|
@ -425,6 +425,33 @@ public class WolfSSLEngine extends SSLEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if current error in WOLFSSL session should be considered
|
||||||
|
* fatal. Used in ClosingConnection() for detection of storing
|
||||||
|
* client cache entry.
|
||||||
|
*
|
||||||
|
* @param ssl WOLFSSL session to check error on
|
||||||
|
*
|
||||||
|
* @return true if error is not fatal, false if fatal
|
||||||
|
*/
|
||||||
|
private synchronized boolean sslErrorNotFatal(WolfSSLSession ssl) {
|
||||||
|
|
||||||
|
int err;
|
||||||
|
|
||||||
|
if (ssl == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = ssl.getError(0);
|
||||||
|
if (err == 0 ||
|
||||||
|
err == WolfSSL.SSL_ERROR_WANT_READ ||
|
||||||
|
err == WolfSSL.SSL_ERROR_WANT_WRITE) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles logic during shutdown
|
* Handles logic during shutdown
|
||||||
*
|
*
|
||||||
|
@ -445,10 +472,17 @@ public class WolfSSLEngine extends SSLEngine {
|
||||||
* not have an active error state, and the session has not been
|
* not have an active error state, and the session has not been
|
||||||
* stored previously. */
|
* stored previously. */
|
||||||
synchronized (ioLock) {
|
synchronized (ioLock) {
|
||||||
if (this.handshakeFinished && (ssl.getError(0) == 0) &&
|
if (this.handshakeFinished && sslErrorNotFatal(ssl) &&
|
||||||
!this.sessionStored) {
|
!this.sessionStored) {
|
||||||
|
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
|
||||||
|
"saving WOLFSSL_SESSION into cache");
|
||||||
this.engineHelper.saveSession();
|
this.engineHelper.saveSession();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
|
||||||
|
"not saving WOLFSSL_SESSION into cache, " +
|
||||||
|
"handshake not complete or already stored");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get current close_notify state */
|
/* get current close_notify state */
|
||||||
|
|
Loading…
Reference in New Issue