问题描述
我是 Tornado 和网络服务的新手.在我的应用程序中,我在服务器端有 Qt/c++ 客户端和 python Tornado.Qt 客户端以文本消息的形式发送命令(例如ws://192.121.1.213:8080?function=myfunction?args=params..").现在,我想使用安全网络套接字,即 wss 代替 ws.服务器端和客户端需要哪些更改?指向任何在线示例的指针也会有所帮助.谢谢.
I'm new to Tornado and web services in general. In my application, I've Qt/c++ client and python Tornado on server side. The Qt client sends commands in the form of text messages(e.g. "ws://192.121.1.213:8080?function=myfunction?args=params..").Now, I want to use secure web socket i.e. wss in stead of ws. What changes are required on server and client side? Pointer to any online example would be also helpful. Thanks.
推荐答案
在构建 HTTPServer
时传递 ssl_options
参数:
Pass the ssl_options
argument when constructing your HTTPServer
:
ssl_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
ssl_ctx.load_cert_chain(os.path.join(data_dir, "mydomain.crt"),
os.path.join(data_dir, "mydomain.key"))
HTTPServer(applicaton, ssl_options=ssl_ctx)
http://www.tornadoweb.org/en/stable/httpserver.html#http-server
这篇关于如何在 Tornado 中使用安全的 websocket (wss)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!