保护 Mosquitto Websocket
Secure Mosquitto Websockets
我安装了 Mosquitto 1.4.9 运行。
我可以在 1883 上发布和订阅
我还可以在 8883 上发布和订阅。8883 使用证书是安全的。
我也可以在 8083 上进行订阅和发布,但只能使用 ws. Wss 将无法连接。
当我启动 Mosquitto 时,日志中出现以下内容:
1521831919: mosquitto version 1.4.9 (build date 2017-12-15 11:14:08-0500) starting
1521831919: Config loaded from /etc/mosquitto/mosquitto.conf
1521831919: Opening ipv4 listen socket on port 1883.
1521831919: Opening ipv6 listen socket on port 1883.
1521831919: Opening ipv4 listen socket on port 8883.
1521831919: Opening ipv6 listen socket on port 8883.
1521831919: Opening websockets listen socket on port 8083.
1521831919: libuv support not compiled in
1521831919: Creating Vhost 'default' port 8083, 3 protocols, IPv6 off
当我尝试使用 Web 界面 (http://hobbyquaker.github.io/mqtt-admin) 进行连接时,我收到一条消息,内容为 Disconnected trying to connect to wss://home.fqdn.com。
在日志中,我看到的唯一条目是:
1521834600: forbidding on uri sanitation
1521834601: lws_read: Unhandled state 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: New client connected from 69.42.179.18 as
mqtt-admin_48154a1b (c1, k60, u'userID').
Mosquitto 版本 1.4.9 在 libwebsockets 中所做的更改无法正常工作。
卸载 mosquitto 并从开发存储库安装 1.4.15,现在 WSS:// 连接正常工作。
我安装了 Mosquitto 1.4.9 运行。
我可以在 1883 上发布和订阅 我还可以在 8883 上发布和订阅。8883 使用证书是安全的。 我也可以在 8083 上进行订阅和发布,但只能使用 ws. Wss 将无法连接。
当我启动 Mosquitto 时,日志中出现以下内容:
1521831919: mosquitto version 1.4.9 (build date 2017-12-15 11:14:08-0500) starting
1521831919: Config loaded from /etc/mosquitto/mosquitto.conf
1521831919: Opening ipv4 listen socket on port 1883.
1521831919: Opening ipv6 listen socket on port 1883.
1521831919: Opening ipv4 listen socket on port 8883.
1521831919: Opening ipv6 listen socket on port 8883.
1521831919: Opening websockets listen socket on port 8083.
1521831919: libuv support not compiled in
1521831919: Creating Vhost 'default' port 8083, 3 protocols, IPv6 off
当我尝试使用 Web 界面 (http://hobbyquaker.github.io/mqtt-admin) 进行连接时,我收到一条消息,内容为 Disconnected trying to connect to wss://home.fqdn.com。 在日志中,我看到的唯一条目是:
1521834600: forbidding on uri sanitation
1521834601: lws_read: Unhandled state 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: New client connected from 69.42.179.18 as mqtt-admin_48154a1b (c1, k60, u'userID').
Mosquitto 版本 1.4.9 在 libwebsockets 中所做的更改无法正常工作。
卸载 mosquitto 并从开发存储库安装 1.4.15,现在 WSS:// 连接正常工作。