我如何建立到本地主机上的websocket的安全连接? [英] How can I establish a secure connection to a websocket on localhost?

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

问题描述

我们在POS终端上运行了一个应用程序,它应该从运行在同一台机器上的应用程序接收数据,同时显示通过HTTPS加载的远程站点的内容。

We have an application which we run on a POS terminal, that should receive data from an application running on the same machine, while displaying content from a remote site which is loaded over HTTPS.

为了从本地应用程序接收数据,我们希望使用websockets,到目前为止它工作正常。但是,当我们显示的网站通过HTTPS加载时,websocket连接也需要加密。

To receive the data from the local application, we want to use websockets, which is working fine so far. However, when the site we're displaying is loaded over HTTPS, the websocket connection is required to be encrypted as well.

因为我们无法真正获得正确的证书对于 localhost ,我们只是使用自签名的。但Chrome不会连接到使用自签名证书的websocket。

Because we can't really get a proper certificate for localhost, we're just using a self-signed one. But Chrome won't connect to a websocket that uses a self-signed certificate.

我们如何解决此问题?我们不能使用未加密的websocket,我们不能为加密的证书使用自签名证书,并且我们无法为 localhost 获取签名证书。我缺少什么选项?

How can we resolve this problem? We can't use an unencrypted websocket, we can't use a self-signed certificate for the encrypted one and we can't get a signed certificate for localhost. What option am I missing?

推荐答案

如果您对POS终端拥有管理权限,那么如何将行添加到HOSTS文件例如:

If you have admin privileges on the POS terminals, how about adding a line to the HOSTS file like:

127.0.0.1 localhost.mycompany.com

现在您可以在服务器应用程序中为 localhost.mycompany.com 使用真实证书。

Now you can use a real certificate for localhost.mycompany.com in the server application.

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

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