spdy-http2 / node-spdy

SPDY server on Node.js
2.8k stars 196 forks source link

Cannot implement strict TLS over request.js #240

Closed olygofren closed 8 years ago

olygofren commented 8 years ago

It seems that node-spdy on both client and server side hides the actual TLSSocket object in a fake net.Socket through a spdy.Handle. However, request.js (quite possibly other libraries too) and even my application code assume that if TLS is involved, sockets available on req/res objects will actually be TLSSockets. This causes code like:

if (req.socket.authorized) ... 
... req.socket.getPeerCertificate() ...

to fail, hence no strict TLS can be implemented without drilling down into node-spdy internals.

So I guess my question is, why the wrapping? Is there any workaround that will allow me to implement strict TLS?

indutny commented 8 years ago

Should be fixed, sorry about this!

The wrapping is required because of the nature of the HTTP2/SPDY protocol. The multiplex multiple requests over the same TLS connection, and the easiest way to present this to node.js is to emulate the socket for each multiplexed request. Thus each request is getting emulated socket, not a real one.

I have added all necessary properties and methods to the emulated socket. Please let me know if it works or doesn't.

Thank you!

olygofren commented 8 years ago

Thanks, I'll give it a try as soon as I get the opportunity. Code seems fine.