ssl - Paho javascript 客户端 + mosquitto Websockets + Tls
问题描述
一段时间以来,我一直在尝试为 mosquitto 代理添加安全层,我需要一些帮助。
我用这个配置配置了我的代理:
...
#logs
#authentication
password_file /etc/mosquitto/passwd
allow_anonymous false
#user
user mosquitto
#broker settings
require_certificate false
listener 8081
protocol websockets
http_dir /var/www/html
keyfile /etc/mosquitto/certs/mqtt-server.key
certfile /etc/mosquitto/certs/mqtt-server.crt
cafile /etc/mosquitto/ca_certificates/mosquitto-certificate-authority.crt
这是日志输出的内容:
1631281308: mosquitto version 2.0.12 starting
1631281308: Config loaded from /etc/mosquitto/mosquitto.conf.
1631281308: Opening websockets listen socket on port 8081.
1631281308: mosquitto version 2.0.12 running
我根据此站点生成了我的证书:https ://www.raspberrypi.org/forums/viewtopic.php?t=287326 。我相信证书没有问题,因为在使用 mosquitto-clients 进行测试时一切正常(在 .conf 文件上评论协议 websockets)。
我从这个站点https://jpmens.net/2014/07/03/the-mosquitto-mqtt-broker-gets-websockets-support/在我的 nginx 服务上上传了一个测试代码,以测试与安全 websockets 的连接,但所有这些给我的是“连接失败:AMQJS0007E 套接字错误:undefined.Retrying”。
你们能帮帮我吗?
解决方案
如果您生成了自己的证书,则需要将 CA 证书导入浏览器,以便它知道信任它来签署代理证书。
与网页不同,当连接由 JavaScript 触发时,浏览器不会提示您信任证书,您需要在尝试连接之前手动执行此操作。
推荐阅读
- latex - “!Extra }”由于编译 Doxygen 生成的 LaTeX 时的 c++ 参数
- django - Django:如何将 2 天添加到用户输入的现有日期
- scala - 如何在 scala 中动态生成类型安全配置(Hocon)文件(生成配置文件)
- javascript - 有条件地移动视频播放头的 Javascript 函数运行两次
- c - X86-64 NASM 调用外部 c 函数
- haskell - 究竟什么是同态?
- python - 提取“这个故事已生成”,公司名称、日期、时间(.txt)并将输出保存到 python 2.7 中的 csv
- java - 在 Spark 中将列的数据集转换为 Json 格式
- matlab - 在matlab中找到彩色图像内的感知冗余
- html - 如何在兄弟姐妹不在背景中时创建灵活高度的背景并保留堆叠顺序