-
Notifications
You must be signed in to change notification settings - Fork 30
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
Add client handshake example #134
Comments
More broadly: I had just assumed that if I was implementing a method named Some ideas though:
|
It seems like this a relevant comment in lib/vtls/rustls.c in the curl repo:
That is indeed pretty unintuitive behavior. We should at a minimum document that on rustls_connection_is_handshaking. And I think you're right - we should have a nice example in-repo of how to do it. Weirdly, some of the other getters like negotiated_cipher_suite may have more intuitive behavior to check for handshake completion - they return None until the handshake is complete, rather than false, true, false.
I don't see where cr_connect_nonblocking writes to an empty buffer. Can you point it out to me? |
I checked, and this is not accurate. is_handshaking starts out true: Lines 615 to 620 in d7a8692
I don't think that behavior changed. I suspect when I wrote that comment, I had just misinterpreted something I'd observed. Additionally, the comment is on a check that is actually first in its loop, so it's not even doing what it says. I'll send a PR. |
I think what I meant by this is, while it is reading and writing data, it's all metadata and connection overhead, it's not writing any of the data that the client wants to send to the server. |
The current model in tests/client.c has a workflow that looks like:
rustls_connection
(which does not involve reading or writing from the socket)Some of the C libraries I've seen have a different workflow - they have API's that look like
cr_connect_nonblocking
in curl)cr_send
incurl
,pgtls_write
in Postgres libpq/fe-secure.c)cr_recv
incurl
,pgtls_read
in Postgres)It might be helpful to add a second example, or break out the logic in the current example so the handshake is performed separately. Especially since as implemented in vtls/rustls.c, the logic to perform a handshake is not obvious (call the write method with an empty buffer), and there's no explicit "handshake" method in crustls.h
Even if it's the same workflow under the hood, conceptually this might help when porting code that currently exists in C.
The text was updated successfully, but these errors were encountered: