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

OpenSSL client doesn't always respond to HelloRequest from server #14722

Open
jay opened this issue Mar 29, 2021 · 3 comments
Open

OpenSSL client doesn't always respond to HelloRequest from server #14722

jay opened this issue Mar 29, 2021 · 3 comments
Labels
triaged: bug The issue/pr is/fixes a bug

Comments

@jay
Copy link
Contributor

jay commented Mar 29, 2021

curl/curl#6785 is curl w/OpenSSL/1.1.1j appears to hang when a second TLS handshake is not completed.

The fail case on a non-blocking socket is basically this:

SSL_write is called with the POST data.
SSL_write returns SSL_ERROR_WANT_WRITE.
Data has arrived (the HelloRequest) and SSL_read is called.
The debug callback shows the HelloRequest was received: * TLSv1.2 (IN), TLS handshake, Hello request (0):
The debug callback does not show that a ClientHello or anything else was sent (normally it would do this).
SSL_read returns SSL_ERROR_WANT_READ
SSL_write is called again and the POST data is sent.
The server does nothing.

Here are my thoughts, from the issue:

The server says the TLS handshake is finished so curl prepares and sends the request. However at almost the exact same time that happens a TLS hello request is received. Then curl is waiting for an HTTP response from the server while at the same time the server is waiting for a handshake response from curl (presumably since nothing else happens but keep alives). I don't know what curl could do here, I would expect it to be handled by OpenSSL.

In the success case SSL_write is called again and succeeds before SSL_read, because the HelloRequest has not yet arrived. Then it arrives and SSL_read is called but this time OpenSSL responds with a ClientHello and completes the handshake.

/cc @danjohansson @bagder

@jay jay added the issue: bug report The issue was opened to report a bug label Mar 29, 2021
@kaduk
Copy link
Contributor

kaduk commented Mar 29, 2021

The scenario here as described seems confusing to me. If SSL_write() returns SSL_ERROR_WANT_WRITE, then shouldn't curl wait for the socket to be writeable? Likewise, SSL_read() returning SSL_ERROR_WANT_READ is not normally a trigger to call SSL_write() again.

That said, this scenario does kind of remind me of #12485 (which I have not had a chance to look into closely).

@kroeckx
Copy link
Member

kroeckx commented Mar 29, 2021 via email

@mattcaswell mattcaswell added triaged: bug The issue/pr is/fixes a bug and removed issue: bug report The issue was opened to report a bug labels Apr 16, 2021
@sundarms
Copy link

Do we have any update or workaround for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaged: bug The issue/pr is/fixes a bug
Projects
None yet
Development

No branches or pull requests

5 participants