JSSE: add debug and close Socket if doHandshake() throws SSLException in startHandshake()
parent
f718187424
commit
59c30d34a7
|
@ -1456,6 +1456,8 @@ public class WolfSSLSocket extends SSLSocket {
|
||||||
@Override
|
@Override
|
||||||
public synchronized void startHandshake() throws IOException {
|
public synchronized void startHandshake() throws IOException {
|
||||||
int ret;
|
int ret;
|
||||||
|
int err = 0;
|
||||||
|
String errStr = "";
|
||||||
|
|
||||||
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
|
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
|
||||||
"entered startHandshake(), trying to get handshakeLock");
|
"entered startHandshake(), trying to get handshakeLock");
|
||||||
|
@ -1506,19 +1508,25 @@ public class WolfSSLSocket extends SSLSocket {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ret = EngineHelper.doHandshake(0, this.getSoTimeout());
|
ret = EngineHelper.doHandshake(0, this.getSoTimeout());
|
||||||
|
err = ssl.getError(ret);
|
||||||
|
errStr = WolfSSL.getErrorString(err);
|
||||||
|
|
||||||
|
/* close socket if the handshake is unsuccessful */
|
||||||
} catch (SocketTimeoutException e) {
|
} catch (SocketTimeoutException e) {
|
||||||
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
|
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
|
||||||
"got socket timeout in doHandshake()");
|
"got socket timeout in doHandshake()");
|
||||||
/* close socket if the handshake is unsuccessful */
|
close();
|
||||||
|
throw e;
|
||||||
|
|
||||||
|
} catch (SSLException e) {
|
||||||
|
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
|
||||||
|
"native handshake failed in doHandshake(): error code: " +
|
||||||
|
err + ", TID " + Thread.currentThread().getId() + ")");
|
||||||
close();
|
close();
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret != WolfSSL.SSL_SUCCESS) {
|
if (ret != WolfSSL.SSL_SUCCESS) {
|
||||||
int err = ssl.getError(ret);
|
|
||||||
String errStr = WolfSSL.getErrorString(err);
|
|
||||||
|
|
||||||
/* close socket if the handshake is unsuccessful */
|
|
||||||
close();
|
close();
|
||||||
throw new SSLHandshakeException(errStr + " (error code: " +
|
throw new SSLHandshakeException(errStr + " (error code: " +
|
||||||
err + ", TID " + Thread.currentThread().getId() + ")");
|
err + ", TID " + Thread.currentThread().getId() + ")");
|
||||||
|
|
Loading…
Reference in New Issue