You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2024/02/15 07:29:49 UTC
(james-project) branch master updated: [FIX] Lower log level of SSL handshake exceptions (#1998)
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
The following commit(s) were added to refs/heads/master by this push:
new a471160588 [FIX] Lower log level of SSL handshake exceptions (#1998)
a471160588 is described below
commit a4711605887cdbe2b0e7a5763480bede1f5f91cb
Author: Benoit TELLIER <bt...@linagora.com>
AuthorDate: Thu Feb 15 08:29:43 2024 +0100
[FIX] Lower log level of SSL handshake exceptions (#1998)
---
.../james/protocols/netty/BasicChannelInboundHandler.java | 10 ++++++++++
.../james/imapserver/netty/ImapChannelUpstreamHandler.java | 10 ++++++++++
2 files changed, 20 insertions(+)
diff --git a/protocols/netty/src/main/java/org/apache/james/protocols/netty/BasicChannelInboundHandler.java b/protocols/netty/src/main/java/org/apache/james/protocols/netty/BasicChannelInboundHandler.java
index 076bda1944..d79138328f 100644
--- a/protocols/netty/src/main/java/org/apache/james/protocols/netty/BasicChannelInboundHandler.java
+++ b/protocols/netty/src/main/java/org/apache/james/protocols/netty/BasicChannelInboundHandler.java
@@ -31,6 +31,8 @@ import java.util.List;
import java.util.Optional;
import java.util.concurrent.ConcurrentLinkedDeque;
+import javax.net.ssl.SSLHandshakeException;
+
import org.apache.james.protocols.api.CommandDetectionSession;
import org.apache.james.protocols.api.Protocol;
import org.apache.james.protocols.api.ProtocolSession;
@@ -51,6 +53,7 @@ import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.handler.codec.DecoderException;
import io.netty.handler.codec.TooLongFrameException;
import io.netty.handler.codec.haproxy.HAProxyMessage;
import io.netty.handler.codec.haproxy.HAProxyProxiedProtocol;
@@ -270,6 +273,8 @@ public class BasicChannelInboundHandler extends ChannelInboundHandlerAdapter imp
}
if (cause instanceof SocketException) {
LOGGER.info("Socket exception encountered: {}", cause.getMessage());
+ } else if (isSslHandshkeException(cause)) {
+ LOGGER.info("SSH handshake rejected {}", cause.getMessage());
} else if (!(cause instanceof ClosedChannelException)) {
LOGGER.error("Unable to process request", cause);
}
@@ -278,6 +283,11 @@ public class BasicChannelInboundHandler extends ChannelInboundHandlerAdapter imp
}
}
+ private boolean isSslHandshkeException(Throwable cause) {
+ return cause instanceof DecoderException &&
+ cause.getCause() instanceof SSLHandshakeException;
+ }
+
@Override
public void pushLineHandler(ChannelInboundHandlerAdapter lineHandlerUpstreamHandler) {
behaviourOverrides.addFirst(lineHandlerUpstreamHandler);
diff --git a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java
index 13b7840122..990a33abd7 100644
--- a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java
+++ b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java
@@ -30,6 +30,8 @@ import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.Set;
+import javax.net.ssl.SSLHandshakeException;
+
import org.apache.james.imap.api.ConnectionCheck;
import org.apache.james.imap.api.ImapConstants;
import org.apache.james.imap.api.ImapMessage;
@@ -59,6 +61,7 @@ import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.handler.codec.DecoderException;
import io.netty.handler.codec.TooLongFrameException;
import io.netty.util.Attribute;
import reactor.core.Disposable;
@@ -274,6 +277,8 @@ public class ImapChannelUpstreamHandler extends ChannelInboundHandlerAdapter imp
try (Closeable closeable = mdc(ctx).build()) {
if (cause instanceof SocketException) {
LOGGER.info("Socket exception encountered: {}", cause.getMessage());
+ } else if (isSslHandshkeException(cause)) {
+ LOGGER.info("SSH handshake rejected {}", cause.getMessage());
} else if (!(cause instanceof ClosedChannelException)) {
LOGGER.warn("Error while processing imap request", cause);
}
@@ -307,6 +312,11 @@ public class ImapChannelUpstreamHandler extends ChannelInboundHandlerAdapter imp
}
}
+ private boolean isSslHandshkeException(Throwable cause) {
+ return cause instanceof DecoderException
+ && cause.getCause() instanceof SSLHandshakeException;
+ }
+
private void manageRejectedException(ChannelHandlerContext ctx, ReactiveThrottler.RejectedException cause) throws IOException {
if (cause.getImapMessage() instanceof AbstractImapRequest) {
AbstractImapRequest req = (AbstractImapRequest) cause.getImapMessage();
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org