You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用mosquitto工具及证书连接Azure Event Grid MQTT代理并实现Pub/Sub

问题:使用mosquitto工具/libmosquitto连接Azure Event Grid MQTT代理失败

我将Azure Event Grid用作MQTT代理,已按照Azure官方生成客户端证书和指纹的教程生成了客户端证书,本地包含根CA证书、客户端证书等相关文件。目前已能通过MQTTX工具完成发布/订阅操作,但无法通过mosquitto工具实现Pub/Sub。

我尝试执行以下订阅命令:

mosquitto_sub -h host.azure.net -p 8883 -t "topic/test/#" --username client-device1 --cafile /home/daniel/.step/certs/root_ca.crt

返回错误:

Error: A TLS error occurred.

使用生成的client-device1-auth-ID.pem文件时也出现相同错误。

此外,我不清楚libmosquitto相关API的参数设置:

mosquitto_username_pw_set(_mosq, kUserName.c_str(), ???);
//或者这里: 
mosquitto_tls_set(_mosq, cafile, capath, certfile, keyfile, callback);

想请教如何通过mosquitto_pub/mosquitto_sub及libmosquitto连接该Azure MQTT代理,问题是否与证书生成时设置的密码短语有关?


内容的提问来源于stack exchange,提问作者user1911091

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 19:03:17