让安全的Websockets在Tornado上运行

sec*_*rve 9 python tornado websocket

如何在Tornado上设置WSS(Secure WebSockets)?

在他们的文档中,他们说以下内容:

WebSocketHandler.get_websocket_scheme可用于在未正确设置的情况下选择适当的URL方案(ws://wss://) HTTPRequest.protocol.

那么,我如何使用get_websocket_scheme和/或HTTPRequest.protocol让WSS在Tornado上工作.

sec*_*rve 13

我知道了 :))

只需将其添加到您的应用程序:

   http_server = tornado.httpserver.HTTPServer(application,ssl_options={
    "certfile": "cert.cer",
    "keyfile":  "key.key",
})
Run Code Online (Sandbox Code Playgroud)

这将解决问题.与常规HTTPS非常相似.我也很欣赏任何其他方式来使它工作.