安全的Mosquitto Websockets

时间:2018-03-23 19:52:50

标签: mqtt mosquitto

我已经安装了Mosquitto 1.4.9。

我可以在1883年发布和发布 我也可以在8883上发布和发布.8888使用证书是安全的。 我也可以在8083上分和发布,但只使用ws。 Wss无法连接。

当我启动Mosquitto时,日志中会出现这样的内容:

  

1521831919:mosquitto版本1.4.9(建立日期2017-12-15 11:14:08-0500)开始
  1521831919:从/etc/mosquitto/mosquitto.conf加载的配置
  1521831919:在端口1883上打开ipv4 listen套接字。
  1521831919:在端口1883上打开ipv6 listen套接字。
  1521831919:在端口8883上打开ipv4 listen套接字。
  1521831919:在端口8883上打开ipv6 listen套接字。
  1521831919:打开websockets侦听端口8083上的套接字。
  1521831919:libuv支持未编译为
  1521831919:创建Vhost'默认'端口8083,3协议,IPv6关闭

当我尝试使用网络界面(http://hobbyquaker.github.io/mqtt-admin)进行连接时,我收到一条消息,指示 已断开连接尝试连接到wss://home.fqdn.com < / strong>即可。 在日志中,我看到的唯一条目是:

  

1521834600:禁止uri环境卫生
  1521834601:lws_read:未处理状态76

当我尝试从命令行连接到8083时:  mosquitto_pub -h home.fqdn.com -t test -m "hello again 2" -p 8083 --capath /etc/ssl/certs/ -u "userID" -P "passWD"

我收到此消息
错误:发生TLS错误。
我假设是因为它来自CLI而不是WSS,因为当我使用-p 8883而不是-p 8083时没有问题。

这是我的配置文件:

pid_file /var/run/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/
persistence_file mosquitto.db
log_dest file /var/log/mosquitto/mosquitto.log
log_type all
websockets_log_level 1023
connection_messages true
log_timestamp true
password_file /etc/mosquitto/pwfile
acl_file /etc/mosquitto/aclfile.acl

#Internal Listener
listener 1883
allow_anonymous false

#External Listener
listener 8883
allow_anonymous false
certfile /etc/letsencrypt/live/home.fqdn.com/cert.pem
cafile /etc/letsencrypt/live/home.fqdn.com/chain.pem
keyfile /etc/letsencrypt/live/home.fqdn.com/privkey.pem

#Webhooks Listener
listener 8083
protocol websockets
http_dir /var/www/html
certfile /etc/letsencrypt/live/home.fqdn.com/cert.pem
cafile /etc/letsencrypt/live/home.fqdn.com/chain.pem
keyfile /etc/letsencrypt/live/home.fqdn.com/privkey.pem

我不明白如何连接WS://而不是WSS://。 8883侦听器不允许不安全的连接,并且它使用相同的证书。

当我连接WS://我在日志中得到这个条目:

  

1521834238:新客户端从69.42.179.18连接为   mqtt-admin_48154a1b(c1,k60,u&#39; userID&#39;)。

1 个答案:

答案 0 :(得分:1)

对于在libwebsockets中进行的更改,Mosquitto 1.4.9版无法正常工作。

卸载了mosquitto并从dev存储库安装了1.4.15,现在WSS://连接正常运行。