Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Websocket无法使用SSL_Websocket_Openssl_Mqtt_Wss - Fatal编程技术网

Websocket无法使用SSL

Websocket无法使用SSL,websocket,openssl,mqtt,wss,Websocket,Openssl,Mqtt,Wss,我已经用MQTT协议创建了一个演示,它可以很好地使用HTTP连接。但当我尝试将HTTP更改为https时,它得到了一个连接错误 我在mosquitto.conf文件中添加了证书路径。让我和你分享一下Mosquitto配置路径 # WebSockets over TLS/SSL listener 8083 protocol websockets cafile /etc/mosquitto/ca_certificates/ca.crt certfile /etc/mosquitto/ca_certi

我已经用MQTT协议创建了一个演示,它可以很好地使用HTTP连接。但当我尝试将HTTP更改为https时,它得到了一个连接错误

我在mosquitto.conf文件中添加了证书路径。让我和你分享一下Mosquitto配置路径

# WebSockets over TLS/SSL
listener 8083
protocol websockets
cafile /etc/mosquitto/ca_certificates/ca.crt
certfile /etc/mosquitto/ca_certificates/hi-todd_com.crt
keyfile /etc/mosquitto/ca_certificates/hi-todd_com.p7b
我使用了下面的库代码

https://www.cloudmqtt.com/docs-websocket.html

现在我们已经解决了所有其他问题

您正在使用的证书的CN为
hi todd.com
,并且有另一个CN为

DNS:hi-todd.com, DNS:www.hi-todd.com
这意味着它只对那些主机有效。在config.js中,您通过主机的IP地址引用主机,因此它与证书不匹配。这将导致浏览器以不安全为由拒绝连接


要解决此问题,请使用主机名而不是ip地址。

请阅读-总结是,这不是向志愿者致意的理想方式,可能会对获得答案产生反作用。请不要将此添加到您的问题中。您是否生成了自己的证书或正在为代理使用公共CA?另外,您是否已在主机服务上的防火墙中打开端口8083,因为我无法连接到
config.js
@hardillb中的ip地址端口。我正在使用公共CA。是的,我的端口已打开。我用相同的端口测试了http,效果很好。目前,我已经更改了mosquitto websocket emqtt的端口和库。但在这个图书馆里也有同样的问题。只使用ws在http中工作8083@hardillb对于http,我使用8083;对于Https,我使用8084。我用过这个图书馆。Http工作正常,但不是https。