【问题标题】:Unable to access root.ca.pem file in AWS IoT Greengrass from Raspberry Pi无法从 Raspberry Pi 访问 AWS IoT Greengrass 中的 root.ca.pem 文件
【发布时间】:2021-03-13 15:41:00
【问题描述】:

我正在尝试从 Raspberry Pi 4 的 IoT 核心发布消息。

import time
from AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTClient

def hello(self,params,packet):
    print("Received Message from AWS IoT Core")
    print(f"Topic: {packet.topic}")
    print(f"Payload: {packet.payload}")

myMQTTClient = AWSIoTMQTTClient("YudhieshID")
// Did not include endpoint here for security reasons
myMQTTClient.configureEndpoint("",8883)

myMQTTClient.configureCredentials("/home/pi/greengrass/certs/root.ca.pem", "/home/pi/greengrass/certs/22e7469561.private.key","/home/pi/greengrass/certs/22e7469561.cert.pem")
myMQTTClient.configureOfflinePublishQueueing(-1)
myMQTTClient.configureDrainingFrequency(2)
myMQTTClient.configureConnectDisconnetTimeout(10)
myMQTTClient.configureMQTTOperationTimeout(5)
print("INtitating IoT Core Topic...")
myMQTTClient.connect()
myMQTTClient.subscribe("home/helloworld",1,hello)

while True:
    time.sleep(5)

错误:

OSError: /home/pi/greengrass/certs/root.ca.pem: No such file or directory

/greengrass/certs 表明文件在那里:

pi@raspberrypi:/greengrass/certs $ tree ./
./
|-- 22e7469561.cert.pem
|-- 22e7469561.private.key
|-- 22e7469561.public.key
|-- README
`-- root.ca.pem

我已经运行以下命令将根 CA 证书下载到 /greengrass/certs 文件夹:

cd /greengrass/certs/
sudo wget -O root.ca.pem https://www.amazontrust.com/repository/AmazonRootCA1.pem

我还使用以下方法确认root.ca.pem 文件不为空:

cat root.ca.pem

【问题讨论】:

    标签: amazon-web-services raspberry-pi aws-iot greengrass


    【解决方案1】:

    设法通过将文件的路径更改为:

    myMQTTClient.configureCredentials("/greengrass/certs/root-ca.pem", "/greengrass/certs/22e7469561.private.key","/greengrass/certs/22e7469561.cert.pem")
    

    但是这样做我必须运行 sudo 来运行 python 脚本才能访问证书。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多