How can I implement a secure WebSocket (wss://) server in Python?

后端 未结 5 2035
情深已故
情深已故 2021-01-31 20:00

I want to serve a real-time stream that has to be securely encrypted due to sensitive data.

I\'ve successfully got normal WebSockets streaming using both gevent and guni

5条回答
  •  借酒劲吻你
    2021-01-31 21:04

    In server side add this to Tornado:

    tornadio2.server.SocketServer(application, ssl_options={
        "certfile": "server.crt",
        "keyfile":  "server.key",
    })
    

    In client side, refer to this link: wss://www.example.com:2201/ws, where the 2201 is the secure Websocket's TLS port.

提交回复
热议问题