三个月有效期的 DigiCert 免费SSL证书。
参考:
https://blog.csdn.net/mgledu/article/details/118573075
https://blog.csdn.net/qq_43547555/article/details/106628783
下载 Nginx PEM/KEY 证书和 根证书
修改:
/etc/mosquitto/mosquitto.conf
增加:
listener 1883 0.0.0.0
listener 8883 0.0.0.0
listener 8884 0.0.0.0
protocol websockets
cafile /etc/mosquitto/ssl/Digicert-OV-DV-root.cer
keyfile /etc/mosquitto/ssl/mqtt1.test.com.key
certfile /etc/mosquitto/ssl/mqtt1.test.com.pem
离线
离线
离线
离线
/etc/mosquitto/mosquitto.conf 这个配置
# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
listener 1883 0.0.0.0
listener 8883 0.0.0.0
cafile /etc/mosquitto/ssl/Digicert-OV-DV-root.cer
certfile /etc/mosquitto/ssl/mqtt1.xxx.com.pem
keyfile /etc/mosquitto/ssl/mqtt1.xxx.com.key
protocol mqtt
listener 8884 0.0.0.0
cafile /etc/mosquitto/ssl/Digicert-OV-DV-root.cer
keyfile /etc/mosquitto/ssl/mqtt1.xxx.com.key
certfile /etc/mosquitto/ssl/mqtt1.xxx.com.pem
protocol websockets
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
这个配置 MQTT, MQTTS, WSS 用MQTTX软件测试均正常了,但是MQTTS用mosquitto_sub测试未成功。
离线
openssl verify Digicert-OV-DV-root.cer
Digicert-OV-DV-root.cer: OK
离线
创建用户名test的密码文件:
mosquitto_passwd -c /etc/mosquitto/passwd test
强制密码登录:
/etc/mosquitto/mosquitto.conf
# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
allow_anonymous false
password_file /etc/mosquitto/passwd
listener 1883 0.0.0.0
listener 8883 0.0.0.0
cafile /etc/mosquitto/ssl/Digicert-OV-DV-root.cer
certfile /etc/mosquitto/ssl/mqtt1.test.com.pem
keyfile /etc/mosquitto/ssl/mqtt1.test.com.key
protocol mqtt
listener 8884 0.0.0.0
cafile /etc/mosquitto/ssl/Digicert-OV-DV-root.cer
keyfile /etc/mosquitto/ssl/mqtt1.test.com.key
certfile /etc/mosquitto/ssl/mqtt1.test.com.pem
protocol websockets
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
这个配置 MQTT, MQTTS, WSS 用MQTTX软件测试均正常,强制账号密码登录,但是MQTTS用mosquitto_sub测试未成功。
离线
搞定了,得用Ubuntu22.04
离线
https://whycan.com/files/members/7106/QQ截图20240407115024.png
搞定了,得用Ubuntu22.04
应该是前面用Ubuntu18.04 的openssl 版本问题,怪不得在google play下载一堆MQTT app都能正常连接到8883端口MQTTS。
离线
memory 说:https://whycan.com/files/members/7106/QQ截图20240407115024.png
搞定了,得用Ubuntu22.04
应该是前面用Ubuntu18.04 的openssl 版本问题,怪不得在google play下载一堆MQTT app都能正常连接到8883端口MQTTS。
到此为止,MQTT,MQTTS,WSS 三种协议完全打通,并且可以互通。
离线
buildroot 2024.02 版本编译出来的,发现嵌入式系统跑不了,也是出错:
# mosquitto_sub -h mqtt2.test.com -t "/control/#" -p 8883 -u test-P test-os.com -d
Client null sending CONNECT
OpenSSL Error[0]: error:0A000086:SSL routines::certificate verify failed
Error: Protocol error
然后一顿骚操作,升级了openssl版本,仍然没有解决,继续跟踪openssl源码,发现需要去找 /etc/ssl 目录
然后把ubuntu 的 /etc/ssl 目录备份解压到 buildroot,OK!
tar cvf /mnt/hgfs/D/s.tar /etc/ssl/ /usr/share/ca-certificates/
离线