Skip to content

Commit

Permalink
8273553: sun.security.ssl.SSLEngineImpl.closeInbound also has similar…
Browse files Browse the repository at this point in the history
… error of JDK-8253368

Backport-of: 0b09f70a730404ceb827673f1d3c82fbf495bb41
  • Loading branch information
GoeLin committed Sep 22, 2022
1 parent 3be9252 commit b75b932
Show file tree
Hide file tree
Showing 3 changed files with 505 additions and 13 deletions.
20 changes: 10 additions & 10 deletions src/java.base/share/classes/sun/security/ssl/SSLEngineImpl.java
Expand Up @@ -48,7 +48,7 @@
import javax.net.ssl.SSLSession;

/**
* Implementation of an non-blocking SSLEngine.
* Implementation of a non-blocking SSLEngine.
*
* @author Brad Wetmore
*/
Expand Down Expand Up @@ -270,7 +270,7 @@ private SSLEngineResult writeRecord(
if (ciphertext == null && !conContext.isNegotiated &&
conContext.isInboundClosed() &&
hsStatus == HandshakeStatus.NEED_WRAP) {
// Even the outboud is open, no futher data could be wrapped as:
// Even the outbound is open, no further data could be wrapped as:
// 1. the outbound is empty
// 2. no negotiated connection
// 3. the inbound has closed, cannot complete the handshake
Expand Down Expand Up @@ -789,17 +789,17 @@ public void closeInbound() throws SSLException {
// Is it ready to close inbound?
//
// No exception if the initial handshake is not started.
if (!conContext.isInputCloseNotified &&
(conContext.isNegotiated ||
conContext.handshakeContext != null)) {

throw conContext.fatal(Alert.INTERNAL_ERROR,
if (!conContext.isInputCloseNotified && (conContext.isNegotiated
|| conContext.handshakeContext != null)) {
throw new SSLException(
"closing inbound before receiving peer's close_notify");
}

conContext.closeInbound();
} finally {
engineLock.unlock();
try {
conContext.closeInbound();
} finally {
engineLock.unlock();
}
}
}

Expand Down
Expand Up @@ -838,9 +838,10 @@ private void shutdownInput(
// No need to throw exception if the initial handshake is not started.
try {
if (checkCloseNotify && !conContext.isInputCloseNotified &&
(conContext.isNegotiated || conContext.handshakeContext != null)) {
throw new SSLException(
"closing inbound before receiving peer's close_notify");
(conContext.isNegotiated ||
conContext.handshakeContext != null)) {
throw new SSLException(
"closing inbound before receiving peer's close_notify");
}
} finally {
conContext.closeInbound();
Expand Down

0 comments on commit b75b932

Please sign in to comment.