Closed szweep closed 10 years ago
Thanks for this. I'm also wondering if we shouldn't simply let tornado perform the wrap_socket call itself.
Probably. I'm no expert on Tornado, but I did see this in the sources for SSLIOStream.init:
If the socket passed to the constructor is already connected,
it should be wrapped with::
ssl.wrap_socket(sock, do_handshake_on_connect=False, **kwargs)
before constructing the `SSLIOStream`. Unconnected sockets will be
wrapped when `IOStream.connect` is finished.
Since the socket is not connected, the wrap_socket in WebSocketBaseClient.init appears to have no effect. I commented out that line and didn't see any change in behavior: an SSL connection was still made, certificate validation worked properly.
The Tornado client's init function uses an SSLIOStream object for SSL communications when using a wss: scheme. The init function for that object will use the optional ssl_options parameter to set parameters used for certificate verification. This change passes the ssl_options (already present in TornadoWebSocketClient.init()) to the SSLIOStream object.