Websocket is not working with SSL

2019-02-16 04:32发布

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条回答
可以哭但决不认输i
2楼-- · 2019-02-16 05:34

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.

查看更多
登录 后发表回答