gaj
gaj

Reputation: 327

How to use secure websocket (wss) in Tornado

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.

Upvotes: 2

Views: 6789

Answers (1)

Ben Darnell
Ben Darnell

Reputation: 22154

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

Upvotes: 4

Related Questions