Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid never ending loop when peer sends close notify during TLS handshake #143

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: avoid never ending loop when peer sends close notify during TLS …
…handshake
  • Loading branch information
felipeek committed Sep 6, 2024
commit e7d19c9b443b5afc5842c3b78182c2919ca18ea2
8 changes: 8 additions & 0 deletions java/src/main/java/org/wildfly/openssl/OpenSSLSocket.java
Original file line number Diff line number Diff line change
@@ -303,6 +303,10 @@ private void runHandshake() throws IOException {
if (write) {
buffer.clear();
result = sslEngine.wrap(EMPTY_DIRECT, buffer);
if (result.getStatus() == SSLEngineResult.Status.CLOSED) {
close();
throw new SSLException(MESSAGES.connectionClosed());
}
if (result.bytesProduced() > 0) {
buffer.flip();
try (DefaultByteBufferPool.PooledByteBuffer indirectPooled = DefaultByteBufferPool.HEAP_POOL.allocate()) {
@@ -336,6 +340,10 @@ private void runHandshake() throws IOException {
buffer.put(indirectPooled.getBuffer());
buffer.flip();
result = sslEngine.unwrap(buffer, unwrappedData.getBuffer());
if (result.getStatus() == SSLEngineResult.Status.CLOSED) {
close();
throw new SSLException(MESSAGES.connectionClosed());
}
if(result.getStatus() == SSLEngineResult.Status.BUFFER_UNDERFLOW) {
underflow = true;
}