Websocket is not working with SSL

倖福魔咒の 提交于 2019-12-19 04:48:26

问题


https://www.hi-todd.com/websocket/

I have created one demo with MQTT protocol and it is working fine with HTTP connection. But when I tried to change HTTP to https then it is getting a connection error.

I have added certificate path in mosquitto.conf file. Let me share with you Mosquitto config path.

# 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

I have used below library code.

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

回答1:


Now we've fixed all the other issues.

The certificate you are using has a CN of hi-todd.com and has alternate CNs of

DNS:hi-todd.com, DNS:www.hi-todd.com

This means it's only valid for those hosts. In your config.js you are referencing the host by it's IP address so it will not match the certificate. This will cause the browser to reject the connection as insecure.

To fix this make your config.js use the hostname not the ip address.



来源:https://stackoverflow.com/questions/45560795/websocket-is-not-working-with-ssl

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