raspberry-pi - Raspberry Pi 中的 Mosquitto 代理设置桥接物联网中心 SAS 令牌
问题描述
因为 IoT Hub 不是代理,所以我想使用 Raspberry Pi 作为设备可以与之通信的代理,并且 Raspberry Pi 将接收到的消息发送到 IoT Hub。在 Raspberry 上安装 Mosquitto 后,这是我的配置 mosquitto 文件:
connection iothub-bridge
log_type all
address your hub.azure-devices.net:8883
remote_username your hub.azure-devices.net/your device
remote_password sas token
remote_clientid your device
bridge_cafile /home/pi/baltimore.pem
try_private false
cleansession true
start_type automatic
bridge_insecure false
bridge_protocol_version mqttv311
bridge_tls_version tlsv1.2
notifications false
notification_topic events/
topic devices/Your device/messages/events/
问题是 SAS 令牌使用了几个小时并且会过期,我想要一个解决方案来替换 SAS TOKEN 并永远工作。
解决方案
很高兴你喜欢我的博客文章:-)。
正如 Matthijs 所说,在设备资源管理器或类似设备中生成 SAS 令牌的最长期限为 365 天,但使用Azure IoT CLI,您可以使用更长的时间。例如,此命令创建一个 10 年(315,360,000 秒)
az iot hub generate-sas-token -n [你的 iot hub] -d [你的设备 id] --du 315360000
正如 Matthijs 所说,你不能生成一个永不过期的。我尝试生成一个 100 年(3,153,600,000 秒),它似乎奏效了
我需要注意的是,我实际上并没有尝试将上面的设备连接到 IoT 中心。
话虽如此,长时间拥有 SAS 代币并不是一个很好的安全实践,但只要你清楚所涉及的风险,我认为这在技术上是可行的。
推荐阅读
- go - qdockwidget 不低于 qmenubar
- java - How to create button opening another window in JavaFx w/o GUI builder, FXML, swing, or awt?
- gremlin - JanusGraph Gremlin Query 的任意图形界面
- r - 循环遍历数据框中的所有列组合
- csv - Apache NiFi:映射具有多列的 csv 以创建新行
- java - Android - Jetpack Navigation
- c - 不指定参数数量的可变参数函数
- python - Selenium webdriver 未关闭,在 python 中没有属性错误
- c# - 具有多个字符串类型参数的 HttpPost。为什么两个参数都为空?
- python - 尝试通过示例代码理解生成器