Skip to content

Commit 6b83527

Browse files
author
Andrey Ershov
authored
Fix plaintext on TLS port logging (#45852)
Today if non-TLS record is received on TLS port generic exception will be logged with the stack-trace. SSLExceptionHelper.isNotSslRecordException method does not work because it's assuming that NonSslRecordException would be top-level. This commit addresses the issue and the log would be more concise.
1 parent e9809b5 commit 6b83527

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/transport/SSLExceptionHelper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ private SSLExceptionHelper() {
1717
}
1818

1919
public static boolean isNotSslRecordException(Throwable e) {
20-
return e instanceof NotSslRecordException && e.getCause() == null;
20+
return e instanceof DecoderException &&
21+
e.getCause() instanceof NotSslRecordException;
2122
}
2223

2324
public static boolean isCloseDuringHandshakeException(Throwable e) {

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/transport/SecurityTransportExceptionHandler.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,7 @@ public void accept(TcpChannel channel, Exception e) {
3030
// just close and ignore - we are already stopped and just need to make sure we release all resources
3131
CloseableChannel.closeChannel(channel);
3232
} else if (SSLExceptionHelper.isNotSslRecordException(e)) {
33-
if (logger.isTraceEnabled()) {
34-
logger.trace(
35-
new ParameterizedMessage("received plaintext traffic on an encrypted channel, closing connection {}", channel), e);
36-
} else {
37-
logger.warn("received plaintext traffic on an encrypted channel, closing connection {}", channel);
38-
}
33+
logger.warn("received plaintext traffic on an encrypted channel, closing connection {}", channel);
3934
CloseableChannel.closeChannel(channel);
4035
} else if (SSLExceptionHelper.isCloseDuringHandshakeException(e)) {
4136
if (logger.isTraceEnabled()) {

0 commit comments

Comments
 (0)