WebSocket安全本地主机连接 [英] WebSocket Secure localhost connection

查看:276
本文介绍了WebSocket安全本地主机连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经构建了一个简单的节点.js WebSocket聊天服务器.

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

我可以在终端选项卡的localhost上运行它.

I can run it on localhost in a terminal tab.

在另一个终端选项卡中,我可以使用ws://通过wscat连接到它.

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

如何使用wss://localhost上连接到它?

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

推荐答案

查看

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.

这篇关于WebSocket安全本地主机连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆