移除X509证书及HSM密钥对后Azure IoT Edge重置设备报错求助
Azure IoT设备重置后证书创建失败的问题解决
核心错误分析
日志中最关键的错误是:无法检索旧设备身份证书(该证书应包含注册所需的通用名字段),这说明设备重置后,身份服务尝试依赖旧证书信息创建新证书,但旧证书已被移除,导致预配流程中断,最终引发aziot-identityd服务启动失败。
解决步骤
- 彻底清理IoT服务残留数据
- 停止相关服务:
sudo systemctl stop aziot-identityd aziot-edged - 删除IoT配置目录:
sudo rm -rf /etc/aziot - 清理软件HSM中的残留密钥与证书(硬件HSM请用对应管理工具清理):
sudo rm -rf /var/lib/aziot/keyd /var/lib/aziot/certd
- 停止相关服务:
- 重新执行设备预配
- 回到IoT Central控制台,获取该设备的最新注册凭证(如X509根证书、注册ID等)
- 按照官方注册流程,重新运行预配命令完成设备身份初始化
- 验证HSM状态
- 确认HSM内已无该设备的旧密钥对,可通过HSM管理工具(如pkcs11-tool)检查并清理残留项
- 确保HSM能正常生成新的密钥对与证书
- 重启服务并验证
- 启动服务:
sudo systemctl start aziot-identityd aziot-edged - 实时查看日志确认恢复情况:
sudo journalctl -u aziot-identityd -f
- 启动服务:
翻译后的报错日志
Sep 22 17:04:11 bobcat systemd[1]: aziot-identityd.service: 已安排重启任务,重启计数器为18119。 Sep 22 17:04:11 bobcat systemd[1]: 已停止Azure IoT身份服务。 Sep 22 17:04:11 bobcat aziot-edged[404821]: 2022-09-22T17:04:11Z [警告] - 守护进程无法成功启动:无法检索设备信息 Sep 22 17:04:11 bobcat aziot-edged[404821]: 2022-09-22T17:04:11Z [警告] - 原因:HTTP请求错误 Sep 22 17:04:11 bobcat aziot-edged[404821]: 2022-09-22T17:04:11Z [警告] - 原因:连接错误:对等方重置连接(系统错误104) Sep 22 17:04:11 bobcat aziot-edged[404821]: 2022-09-22T17:04:11Z [警告] - 请求重新预配设备。 Sep 22 17:04:11 bobcat aziot-edged[404821]: 2022-09-22T17:04:11Z [警告] - 重新预配操作失败 Sep 22 17:04:11 bobcat systemd[1]: 已启动Azure IoT身份服务。 Sep 22 17:04:11 bobcat aziot-identityd[404892]: 2022-09-22T17:04:11Z [错误!] - 无法通过IoT Hub预配,且未找到有效的设备备份:内部错误 Sep 22 17:04:11 bobcat aziot-identityd[404892]: 2022-09-22T17:04:11Z [错误!] - 服务遇到错误 Sep 22 17:04:11 bobcat aziot-identityd[404892]: 2022-09-22T17:04:11Z [错误!] - 原因:内部错误 Sep 22 17:04:11 bobcat aziot-identityd[404892]: 2022-09-22T17:04:11Z [错误!] - 原因:无法创建证书 Sep 22 17:04:11 bobcat aziot-identityd[404892]: 2022-09-22T17:04:11Z [错误!] - 原因:内部错误 Sep 22 17:04:11 bobcat aziot-identityd[404892]: 2022-09-22T17:04:11Z [错误!] - 原因:无法创建证书 Sep 22 17:04:11 bobcat aziot-identityd[404892]: 2022-09-22T17:04:11Z [错误!] - 原因:无法检索旧设备身份证书(该证书应包含注册所需的通用名字段) Sep 22 17:04:11 bobcat aziot-identityd[404892]: 2022-09-22T17:04:11Z [错误!] - 0: <未知> Sep 22 17:04:11 bobcat aziot-identityd[404892]: 1: <未知> Sep 22 17:04:11 bobcat aziot-identityd[404892]: 2: <未知> Sep 22 17:04:11 bobcat aziot-identityd[404892]: 3: <未知> Sep 22 17:04:11 bobcat aziot-identityd[404892]: 4: <未知> Sep 22 17:04:11 bobcat aziot-identityd[404892]: 5: <未知> Sep 22 17:04:11 bobcat aziot-identityd[404892]: 6: <未知> Sep 22 17:04:11 bobcat aziot-identityd[404892]: 7: <未知> Sep 22 17:04:11 bobcat aziot-identityd[404892]: 8: <未知> Sep 22 17:04:11 bobcat aziot-identityd[404892]: 9: <未知> Sep 22 17:04:11 bobcat aziot-identityd[404892]: 10: <未知> Sep 22 17:04:11 bobcat aziot-identityd[404892]: 11: __libc_start_main Sep 22 17:04:11 bobcat aziot-identityd[404892]: 12: <未知> Sep 22 17:04:11 bobcat systemd[1]: aziot-identityd.service: 主进程退出,代码=退出,状态=1/失败 Sep 22 17:04:11 bobcat systemd[1]: aziot-identityd.service: 失败,结果为'exit-code'。
内容的提问来源于stack exchange,提问作者neer2005
相关产品推荐
相关产品推荐

