snapview / tungstenite-rs

Lightweight stream-based WebSocket implementation for Rust.
Apache License 2.0
1.87k stars 215 forks source link

client_tls, stream is not upgradeable? #402

Closed dozepih closed 8 months ago

dozepih commented 8 months ago

https://github.com/snapview/tungstenite-rs/blob/2ee05d10803d95ad48b3ad03d9d9a03164060e76/src/tls.rs#L162

Is this really true? Tried sending in a TlsStream<TcpStream> with the result of: TLS error: native-tls error: unexpected EOF but just using a <TcpStream> works fine.

daniel-abramov commented 8 months ago

Yes, this is true 🙂 However, we can't identify if the stream is encrypted (we don't know anything about the stream except that it's Read and Write). We decide if we need to wrap the stream based on the protocol ws:// vs wss://. So if you supply a stream X with wss:// URL, we would try to "upgrade" the stream to use TLS.