Pithikos / python-websocket-server

A simple fully working websocket-server in Python with no external dependencies
MIT License
1.14k stars 381 forks source link

SSL support #35

Closed chatango-kotarou closed 3 years ago

chatango-kotarou commented 6 years ago

any chances of ssl/tls support?

Pithikos commented 6 years ago

If someone implemented it, I might consider adding it. But personally I don't have much free time to do the implementation.

Tythos commented 5 years ago

ssl.wrap_socket could be used to extend WebsocketServer, according to a StackOverflow article I no longer seem to be capable of finding. For web application development, though, the ideal case is to connect back to the same server that provided the original client files so you don't have to worry about CORS security. I've found CherryPy to be an effective way to mount both HTTPS hosting and WebSocket handlers within the same configuration, although Tornado should work, too.

Right now, I'm focusing on subclassing WebsocketServer, but I can put in a PR if you are interested (and if I can get something to work). I'm not a networking expert, so I'm not sure how much time it will take.

Jawmo commented 5 years ago

I would absolutely love to see this. When I tried implementing certbot, everything works fine and I can get https from the server, but I cannot figure out how to get the wss working with this library. I've tried upgrading headers, etc. but if there is an elegant solution to getting this working, this would be a life saver!

Tythos commented 5 years ago

I've focused on flask+gevent since I wrote the above comment, which has all the advantages I mentioned with the streamlined and minimal configuration of a Flask-based WSGI object. It's a much more efficient way to manage server configurations (especially if you're containerizing the service, as I do a lot) when you can separate socket security from the exchange handlers (HTTPS, WSS).

Pithikos commented 3 years ago

This has now been added thanks to @eado