WebSocket Secure localhost connection

会有一股神秘感。 提交于 2020-01-14 02:53:28

问题


I've built a simple Node.js WebSocket chat server.

I can run it on localhost in a terminal tab.

In another terminal tab, I can connect to it with wscat, using ws://.

How do I connect to it on localhost with wss://?


回答1:


Look at this example code for how to establish an HTTPS server which will handle the TCP and TLS layers and then the ws module can handle the websocket aspects integrating with that server. You'll need a TLS certificate. For development you can generate your own and sign it yourself. A web search for "self-signed certificate" should lead you to the info you need for that part.



来源:https://stackoverflow.com/questions/19469445/websocket-secure-localhost-connection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!