-
Notifications
You must be signed in to change notification settings - Fork 1
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
TLS1.3 WIP #2
TLS1.3 WIP #2
Conversation
1322f5a
to
5dd6efd
Compare
a339f36
to
e851ba5
Compare
e7e4377
to
998d8dd
Compare
e851ba5
to
b4e670d
Compare
07aa3c3
to
af228b3
Compare
d77be64
to
07346c3
Compare
2487c32
to
393f932
Compare
Cherry-pick: openssl/openssl@4af5836 Original-Pr: openssl/openssl#8096
Allow enabling/disabling 1.3, as well as disabling 1.2.
What appears to be happening is that `SSL_write()` is writing the 5 bytes of `hello`, but it isn't being flushed out as encrypted text into the BIO. This might be because its in the middle of SSL code where the info callback is called, but its about to send the NewTickets, so the data is just buffered briefly before encrypting it out in an appdata record. Just a guess. Since there is nothing to flush, the code wanders down to EncOut(), where it sees there is nothing to write, so it calls InvokeQueued, which does a sync w->Done(), in violation of the DoWrite() contract. XXX There is an open question of exactly when to call it. Sync is illegal, SetImmediate() works, but it seems to me it shouldn't be called until the data that went into SSL_write() comes out of EncOut() and into the next stream, and the next stream callbacks, that Done() should happen. Tried to make the latter change, but it makes no difference to the unit tests, so I've no idea if its right or not.
Code passes with the work-around, but it's a bug. Not sure how to fix. Calling SSL_read after after a close_notify is a bit dicy, but might have to do that, but make sure that only 'session' events occur (ie., discard data and anything else). Seems subtly wrong. Have asked openssl list how this is supposed to work. This only happens with servers that .end() sync with no data in the secureConnection event, and maybe those servers don't deserve ticket support? Not sure.
Sometimes it does, sometimes it doesn't, I'm not sure if this expected streams behaviour, or not. Compare this test with test/parallel/test-tls-invoke-queued.js.
This is a bug, it isn't supposed to happen, but how to prevent it? When TLS finishes the DoWrite the underlying stream is closed, so the stream_resource()->Write() in EncOut() fails with write-after-destroy. See test/parallel/test-tls-destroy-stream.js, and its inline comments.
393f932
to
0db2eed
Compare
@sam-github Is that still the current state? I have time to look into this now and this test passes for me :) I am seeing other failures, though, and I’ll look at the source code changes here and try to understand them. |
void SecureContext::SetCiphers(const FunctionCallbackInfo<Value>& args) { | ||
#if 1 | ||
#define fprintf(...) | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note: Debug()
from debug_utils.h
might have something – it works out-of-the-box for async wraps, since they already have a limited set of names, but it should be easy enough to add other categories?
@@ -214,6 +214,8 @@ class StreamResource { | |||
// Return 0 for success and a libuv error code for failures. | |||
virtual int DoTryWrite(uv_buf_t** bufs, size_t* count); | |||
// Perform a write of data, and either call req_wrap->Done() when finished | |||
// call when? can we call sync? "call Done() and return" suggests | |||
// first Done, then return, but probably not right |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We’re not strict about this – basically, your options are:
- return
0
. This means you can callDone()
at any point, which is almost always asynchronous but might not need to be. - return an error code.
current state is described in the last few commits, the XXX ones, I tried to comment the test cases themselves, the commits might or might not be informative I will check, but I'm pretty convinced that returning calling ->Done() then returning You can confirm by removing the SetImmediate wrapper (its commented) in EncOut(). I've some docs locally, just about half an hour away from being done them at which point I'll pr it to node, though I won't have time to look at it until this evening. The last outstanding problems are pretty well defined:
|
The
I’ll try that.
Sounds good!
Yup, you’re right. The TLS code has always been weird about this, though, I think.
Yeah, I’ll take a look at that.
I think this is something you understand better than me :) |
What I’m getting for the
That seems kind of expected to me? |
Compare that one to this one:
EDIT: ----^ this is one of the failures that leaves me stumped. I cannot find any sign that tlsSocket.destroy() calls ANY C++ method of TLSWrap. I believe it is either bypassing it, and closing the underlying stream, or that .destroy() is calling some base class method that I haven't found yet, and that is closing the underlying stream. Either way, its broken, and until I can find the code, I cannot even guess as to why its different for TLS1.3 when it works for TLS1.2. |
Btw, its a holiday weekend here, and I'm alone with my kids, so apologies in advance, my responsiveness will be a bit limited, though I'm trying to keep an eye on email. Back at my desk Tuesday. |
Edit, sorry. The above is a problem, but in f978966, I suggest comparing it to test/parallel/test-tls-invoke-queued.js. Note that in that particular configuration:
ALL three writes get to the client, but with the -multi variant:
NONE of the writes get to the client. I dunno, maybe that makes sense? The ordering difference between the last write and the destroy is different, but its very subtly different. As I say in the commit/comment for the -multi.js test, maybe it makes sense, maybe not, I'm not sure. I am sure that absolutely no amount of reading of the streams docs would give anyone a to predict the behaviour of either test. |
No description provided.