Add more debug informations when log SSL errors. (#8241)
Motivation:
ea626ef8c3
added more debug logging but we can even include a bit more.
Modifications:
Always log the error number as well.
Result:
More informations for debugging SSL errors.
This commit is contained in:
parent
38eee409c8
commit
a644563625
@ -856,21 +856,22 @@ public class ReferenceCountedOpenSslEngine extends SSLEngine implements Referenc
|
|||||||
* Log the error, shutdown the engine and throw an exception.
|
* Log the error, shutdown the engine and throw an exception.
|
||||||
*/
|
*/
|
||||||
private SSLException shutdownWithError(String operations, int sslError) {
|
private SSLException shutdownWithError(String operations, int sslError) {
|
||||||
String err = SSL.getLastError();
|
return shutdownWithError(operations, sslError, SSL.getLastErrorNumber());
|
||||||
return shutdownWithError(operations, sslError, err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private SSLException shutdownWithError(String operation, int sslError, String err) {
|
private SSLException shutdownWithError(String operation, int sslError, int error) {
|
||||||
|
String errorString = SSL.getErrorString(error);
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("{} failed with {}: OpenSSL error: {}", operation, sslError, err);
|
logger.debug("{} failed with {}: OpenSSL error: {} {}",
|
||||||
|
operation, sslError, error, errorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
// There was an internal error -- shutdown
|
// There was an internal error -- shutdown
|
||||||
shutdown();
|
shutdown();
|
||||||
if (handshakeState == HandshakeState.FINISHED) {
|
if (handshakeState == HandshakeState.FINISHED) {
|
||||||
return new SSLException(err);
|
return new SSLException(errorString);
|
||||||
}
|
}
|
||||||
return new SSLHandshakeException(err);
|
return new SSLHandshakeException(errorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final SSLEngineResult unwrap(
|
public final SSLEngineResult unwrap(
|
||||||
@ -1120,7 +1121,7 @@ public class ReferenceCountedOpenSslEngine extends SSLEngine implements Referenc
|
|||||||
SSL.clearError();
|
SSL.clearError();
|
||||||
return new SSLEngineResult(OK, NEED_WRAP, bytesConsumed, bytesProduced);
|
return new SSLEngineResult(OK, NEED_WRAP, bytesConsumed, bytesProduced);
|
||||||
}
|
}
|
||||||
throw shutdownWithError("SSL_read", error, SSL.getErrorString(stackError));
|
throw shutdownWithError("SSL_read", error, stackError);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void closeAll() throws SSLException {
|
private void closeAll() throws SSLException {
|
||||||
@ -1269,7 +1270,8 @@ public class ReferenceCountedOpenSslEngine extends SSLEngine implements Referenc
|
|||||||
int sslErr = SSL.getError(ssl, err);
|
int sslErr = SSL.getError(ssl, err);
|
||||||
if (sslErr == SSL.SSL_ERROR_SYSCALL || sslErr == SSL.SSL_ERROR_SSL) {
|
if (sslErr == SSL.SSL_ERROR_SYSCALL || sslErr == SSL.SSL_ERROR_SSL) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("SSL_shutdown failed: OpenSSL error: {}", SSL.getLastError());
|
int error = SSL.getLastErrorNumber();
|
||||||
|
logger.debug("SSL_shutdown failed: OpenSSL error: {} {}", error, SSL.getErrorString(error));
|
||||||
}
|
}
|
||||||
// There was an internal error -- shutdown
|
// There was an internal error -- shutdown
|
||||||
shutdown();
|
shutdown();
|
||||||
|
Loading…
Reference in New Issue
Block a user