Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…3099) Motivation: When a channel is closed during the SSL handshake then `java.nio.channels.ClosedChannelException` is thrown. This is correct when we see it from a low-level transport perspective but from a high-level, this error is not detailed enough to debug. And when we log `ClosedChannelException`, we get this line: `java.nio.channels.ClosedChannelException: null` in the stack trace. Modification: To combat this, we should throw `StacklessSSLHandshakeException` with the message `"Connection closed while SSL/TLS handshake was in progress"` as suppressed with`ClosedChannelException`. This will explicitly declare that the handshake failed due to connection closure. Result: Fixes #12000 Co-authored-by: Idel Pivnitskiy <idel.pivnitskiy@apple.com>
- Loading branch information
1 parent
b8d8ee1
commit bd7b70d
Showing
3 changed files
with
55 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
handler/src/main/java/io/netty5/handler/ssl/StacklessSSLHandshakeException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2023 The Netty Project | ||
* | ||
* The Netty Project licenses this file to you under the Apache License, | ||
* version 2.0 (the "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at: | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package io.netty5.handler.ssl; | ||
|
||
import javax.net.ssl.SSLHandshakeException; | ||
|
||
/** | ||
* A {@link SSLHandshakeException} that does not fill in the stack trace. | ||
*/ | ||
final class StacklessSSLHandshakeException extends SSLHandshakeException { | ||
|
||
private static final long serialVersionUID = -1244781947804415549L; | ||
|
||
/** | ||
* Constructs an exception reporting an error found by | ||
* an SSL subsystem during handshaking. | ||
* | ||
* @param reason describes the problem. | ||
*/ | ||
StacklessSSLHandshakeException(String reason) { | ||
super(reason); | ||
} | ||
|
||
@Override | ||
public Throwable fillInStackTrace() { | ||
// This is a performance optimization to not fill in the | ||
// stack trace as this is a stackless exception. | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters