-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
Different behaviour between new tls.TLSSocket() followed by connect(..) versus tls.connect(..) #30468
Comments
Can you elaborate why you need the I solved a similar problem by creating a |
My understanding of the * - nodejs seem to support returning See https://nodejs.org/api/net.html#net_net_createconnection In my case I need to initially connect a That is not possible to achieve synchronously. So I'm hoping to achieve it by creating the tlsSocket object initially and having it
I don't understand that solution. If someone calls Currently I'm returning
i.e. I return a Proxy of the socket which I mark as not connected (writable) until the tlsSocket is connected. But this does not work due to the issue above. |
TCP sockets and TLS sockets are |
Excuse my ignorance but can you provide an example or hints on how to set that up? I've experience with streams but I'm not After looking through the _tls_wrap.js code in node.js, and further experiments, I'm coming to the conclusion that it's not possible to create a new TLSSocket(..) object without having it start a connection. I had assumed it should be possible by not passing in any arguments to the constructor and manually calling |
If you need to perform custom steps between connecting the TCP socket and performing the TLS handshake, think of your code as an additional network layer that is between TCP and TLS. I did something similar for a network protocol prototype recently. The code isn't great, but I hope it will demonstrate what I mean :)
|
This issue seems to have run its course. I'll go ahead and close it out. |
Agree with the closure. In case it helps in the end I had to remove the OCSP module and rely upon the callback approach (which accidentally works for TLS). While it "feels" reasonable for the above approach to work in reality this section of the core code is (IMO) not well written and a little inconsistent with itself. i.e. As the above solution would work for a TCP, but not for a TLS, connection. |
Feel free to propose / implement a fix :) |
A more than fair response. Internally I cringe at the idea of how many libraries, projects, etc I'd break. |
I'm implementing proxy support as well and got overwhelmed about how difficult is to inject some custom code between plain socket and tls. TLS supports starting and closing secure channel at any time over an existing connection, I suppose this would be a nightmare to implement in Node whereas it should be as simple as
or even
|
I'm not sure whether this is an incorrect usage issue or a follow up of #3963. Alternatively it may be covered by documentation I missed or may need to be added.
I'm adding enterprise proxy (NTLM, Kerberos) support to the tls module by overriding the
createConnection
method and using the SSPI native library on Windows.To do this I'm attempting to use the following code to create a TLS Socket in nodejs
But this is causing an ECONNREFUSED error indicating that the socket setup is not taking affect with tlsSocket. The events I see in this flow on tlsSocket are
But if I change the code to
It works and the tlsSocket events are
Why does this fail if I create the constructor version of the TLSSocket and connect it later? i.e. Rather than when I use tls.connect(..) which passes.
I need the reference to tlsSocket so the
createConnection
function can return it immediately. I have been able to use thecreateConnection
callback instead with the second approach. However this brakes an OCSP agent I'm using. i.e. As it incorrectly (I think) assumescreateConnection
always returns the socket object rather than undefined followed by a callback.The text was updated successfully, but these errors were encountered: