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

Close socket if handshake fails #205

Merged
merged 2 commits into from
Jun 27, 2024

Conversation

sstefonic
Copy link
Contributor

The following changes help wolfJSSE align more closely with standards outlined in the javadocs:

  • Ensure that if the implicit handshake in SSLSocket.getSession() fails, the socket is closed
  • If the handshake fails in getSession(), return an invalid SSLSession object with the invalid cipher suite "SSL_NULL_WITH_NULL_NULL"
  • If any handshake is unsuccessful, close the socket before throwing an exception

https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLSocket.html

@sstefonic sstefonic assigned sstefonic and cconlon and unassigned sstefonic Jun 14, 2024
@@ -1297,6 +1297,20 @@ public synchronized SSLSession getSession() {
/* Log error, but continue. Session returned will be empty */
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
"Handshake attempt failed in SSLSocket.getSession()");

/* close SSLSocket */
if (this.socket != null && !this.socket.isClosed()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this socket null/isClosed check? Since we call close() anyways, doesn't that check for this internal to that method?

@cconlon cconlon assigned sstefonic and unassigned cconlon Jun 27, 2024
@sstefonic sstefonic assigned cconlon and unassigned sstefonic Jun 27, 2024
@cconlon cconlon merged commit a352475 into wolfSSL:master Jun 27, 2024
35 checks passed
@sstefonic sstefonic deleted the handshakeFailureClose branch July 22, 2024 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants