【发布时间】:2020-04-01 20:06:04
【问题描述】:
我正在开发一个应用程序,总而言之,它使用 MQTT 将传感器值发送到代理,以便稍后在仪表板 Web 应用程序中可视化该数据。 我有五个微控制器连接到代理,并且我为代理设置了服务器证书,并为每个微控制器设置了客户端证书。
问题是,在 mosquitto.conf 文件中,我需要为想要连接的客户端使用客户端证书,所以如果我想从我的 Web 应用程序订阅主题,我需要一个客户端证书。我正在尝试找到完成此任务的正确方法,但在您无法控制的机器中拥有证书和密钥似乎是一个很大的安全风险。
如果有人知道调整 mosquitto 配置文件的方法或建立某种异常(可能类似于 ACL)以仅要求某些客户端(在我的情况下为微控制器)的客户端证书并使用用户名@,那将是理想的其他人(网络客户端)的密码。有可能做这样的事情吗?
任何帮助将不胜感激
编辑(关于@hardillb 的回答)
我的 mosquitto.conf:
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
per_listener_settings true
listener 9873
protocol websockets
#http_dir /home/jamengual/Desktop/UIB/TFG/mqtt/webAPP
cafile /etc/mosquitto/ca_certificates/ca.crt
keyfile /etc/mosquitto/certs/server.key
certfile /etc/mosquitto/certs/server.crt
listener 8883
cafile /etc/mosquitto/ca_certificates/ca.crt
keyfile /etc/mosquitto/certs/server.key
certfile /etc/mosquitto/certs/server.crt
require_certificate true
“per_listener_settings true”使服务器进入活动(退出)状态。 来自 mosquitto.conf 指南:
谈谈认证机制:
基于证书和 PSK 的加密均配置在 每个听众的基础。
谈论 per_listener_settings 选项:
per_listener_settings [ true | false ]
If true, then authentication and access control settings will be controlled on a per-listener basis. The following options are affected:
password_file, acl_file, psk_file, allow_anonymous, allow_zero_length_clientid, auth_plugin, auth_opt_*, auto_id_prefix.
所以我知道 per_listener_settings 选项对于 require_certificate 部分可能不是必需的。但是,我仍然需要它来配置 websockets 的用户名和密码。
我的配置文件有问题吗?
Link to my question about how to store client certificates and keys in the client's machine
【问题讨论】:
标签: ssl ssl-certificate mqtt mosquitto