【问题标题】:Error using TPM with IoT Edge on Yocto after running tpm2_takeowership运行 tpm2_takeowership 后在 Yocto 上使用带有 IoT Edge 的 TPM 时出错
【发布时间】:2019-08-20 20:48:53
【问题描述】:

将 IoT Edge 配置为使用 TPM,我收到错误消息:错误:没有这样的文件或目录(操作系统错误 2)

我之前运行过 tpm2_takeownership,所以这可能是一个促成因素。

操作系统:Yocto 2.3(Linux reliagate-10-12 4.9.148-eurotech-ti #1 Tue May 21 12:52:42 UTC 2019 armv7l armv7l armv7l GNU/Linux)

如果我不使用 TPM,IoT Edge 运行良好。

我已经能够按照此处列出的 tpm_device_provision 说明进行操作:https://docs.microsoft.com/en-us/azure/iot-edge/how-to-auto-provision-simulated-device-linux 并获得以下输出(意味着我可以成功与 TPM 通信)。

root@reliagate-10-12:eMMC:~# ./tpm_device_provision
Gathering the registration information...

Registration Id:
2upzntec--REMOVED--drlxrtza

Endorsement Key:
AToAAQAL--REMOVED--9zGxyw==

Press any key to continue:

我对我的 config.yaml 进行了以下更改

provisioning:
  source: "dps"
  global_endpoint: "https://global.azure-devices-provisioning.net"
  scope_id: "0ne00045676"
  attestation:
    method: "tpm"
    registration_id: "2upzntec--REMOVED--drlxrtza"

我已对 tpm 进行了必要的权限更改:

root@reliagate-10-12:eMMC:~# ls -all /dev/tpm0
crw-rw----. 1 tss iotedge 10, 224 May 16 14:44 /dev/tpm0

我已在 iotedge.service 中授予设置

root@reliagate-10-12:eMMC:~# systemctl cat iotedge.service
[Unit]
Description=Azure IoT Edge daemon
After=network-online.target docker.service iotedge.socket     iotedge.mgmt.socket
Requires=iotedge.socket iotedge.mgmt.socket
Wants=network-online.target docker.service
Documentation=man:iotedged(8)

[Service]
ExecStart=/usr/bin/iotedged -c /etc/iotedge/config.yaml
KillMode=process
TimeoutStartSec=600
TimeoutStopSec=40
Restart=on-failure
User=iotedge
Group=iotedge

[Install]
WantedBy=multi-user.target
Also=iotedge.socket iotedge.mgmt.socket

# /etc/systemd/system/iotedge.service.d/override.conf
[Service]
Environment=IOTEDGE_USE_TPM_DEVICE=ON

我已启用 tpmaccess 规则:

root@reliagate-10-12:eMMC:~# cat /etc/udev/rules.d/tpmaccess.rules
#allow iotedge access to tpm0
KERNEL=="tpm0", SUBSYSTEM=="tpm", GROUP="iotedge", MODE="0660"

但是当我运行 journalctl -u iotedge --no-pager --no-full 时,我看到以下错误

8 月 20 日 20:38:22 reliagate-10-12 systemd[1]:启动 Azure IoT Edge 守护程序。 8 月 20 日 20:38:22 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:22Z [INFO] - 使用配置文件:/etc/iotedge/config.yaml 8 月 20 日 20:38:22 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:22Z [INFO] - 启动 Azure IoT Edge 安全守护进程 8 月 20 日 20:38:22 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:22Z [INFO] - 版本 - 1.0.7 8 月 20 日 20:38:22 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:22Z [INFO] - 使用运行时网络 id azure-iot-edge 8 月 20 日 20:38:22 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:22Z [INFO] - 正在初始化模块运行时... 8 月 20 日 20:38:22 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:22Z [INFO] - 正在初始化模块运行时... 8 月 20 日 20:38:22 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:22Z [INFO] - 成功初始化模块运行时 8 月 20 日 20:38:22 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:22Z [INFO] - 已完成模块运行时的初始化。 8 月 20 日 20:38:22 reliagate-10-12 iotedge[3466]: 2019-08-20T20:38:22Z [INFO] - 将 /var/lib/iotedge 配置为主目录。 8 月 20 日 20:38:22 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:22Z [INFO] - 配置证书... 8 月 20 日 20:38:22 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:22Z [INFO] - 找不到透明网关证书,在快速启动模式下运行... 8 月 20 日 20:38:22 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:22Z [INFO] - 完成配置证书。 8 月 20 日 20:38:22 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:22Z [INFO] - 正在初始化 hsm... 8 月 20 日 20:38:22 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:22Z [INFO] - 完成初始化 hsm。 8 月 20 日 20:38:22 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:22Z [INFO] - 检测配置文件是否已更改... 8 月 20 日 20:38:22 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:22Z [INFO] - 未检测到对配置文件的更改。 8 月 20 日 20:38:22 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:22Z [INFO] - 成功获取工作负载 CA。 8 月 20 日 20:38:22 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:22Z [INFO] - 配置边缘设备... 8 月 20 日 20:38:22 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:22Z [INFO] - 开始通过 TPM 配置边缘设备... 8 月 20 日 20:38:22 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:22Z [INFO] - 使用 scope_id “0ne00045676”、registration_id “2upzntec--REMOVED--drlxrtza”开始 DPS 注册 8 月 20 日 20:38:23 reliagate-10-12 iotedged [3466]: 2019-08-20T20:38:23Z [警告] - 无法配置设备 8 月 20 日 20:38:23 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:23Z [WARN] - 原因:无法获得 TPM 挑战密钥 8 月 20 日 20:38:23 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:23Z [WARN] - 原因:密钥库中发生错误。 8 月 20 日 20:38:23 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:23Z [WARN] - 原因:HSM 故障 8 月 20 日 20:38:23 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:23Z [WARN] - 原因:发生 HSM API 故障:342 8 月 20 日 20:38:23 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:23Z [ERR!] - 守护进程无法成功启动:无法初始化 DPS 配置客户端 8 月 20 日 20:38:23 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:23Z [ERR!] - 原因:无法恢复以前的配置结果 8 月 20 日 20:38:23 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:23Z [ERR!] - 原因:没有这样的文件或目录(操作系统错误 2) 8 月 20 日 20:38:23 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:23Z [ERR!] (/home/build/my_project/yocto/build/tmp/work/cortexa8hf-neon-用于 EK 的 poky-linux-gnueabi/libiothsm-std/1.0.7-r0/iotedge-1.0.7/edgelet/hsm-sys/azure-...icySecret() 8 月 20 日 20:38:23 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:23Z [ERR!] (/home/build/my_project/yocto/build/tmp/work/cortexa8hf-neon- poky-linux-gnueabi/libiothsm-std/1.0.7-r0/iotedge-1.0.7/edgelet/hsm-sys/azure-... EK 策略会话 8 月 20 日 20:38:23 reliagate-10-12 iotedged[3466]: 2019-08-20T20:38:23Z [ERR!] (/home/build/my_project/yocto/build/tmp/work/cortexa8hf-neon- poky-linux-gnueabi/libiothsm-std/1.0.7-r0/iotedge-1.0.7/edgelet/hsm-sys/azure-...将密钥输入 tpm 8 月 20 日 20:38:23 reliagate-10-12 systemd[1]: iotedge.service: 主进程退出,code=exited,status=1/FAILURE 8 月 20 日 20:38:23 reliagate-10-12 systemd[1]:iotedge.service:失败,结果为“退出代码”。 8 月 20 日 20:38:23 reliagate-10-12 systemd[1]: iotedge.service: Service RestartSec=100ms expired,调度重启。 8 月 20 日 20:38:23 reliagate-10-12 systemd[1]:iotedge.service:计划重启作业,重启计数器为 5。 8 月 20 日 20:38:23 reliagate-10-12 systemd[1]:已停止 Azure IoT Edge 守护进程。

【问题讨论】:

    标签: azure-iot-edge tpm


    【解决方案1】:

    一些想法:

    1. 您是否正在运行最新的 IoT Edge 位 (1.0.8)?
    2. 仔细检查 DPS 中的范围和背书密钥。
    3. 我们已经看到 IoT Edge 在 TPM 准备好之前出现的初始化问题。您可能必须配置 systemd 以使 iotedged 启动更慢。在这种情况下,iotedged 依赖于 TPM。
    4. 您是否正在运行 TPM 资源管理器?

    谢谢, 凯文

    【讨论】:

    • Yocto 层只有 1.0.7 版 (github.com/Azure/meta-iotedge)。我检查了范围和设备 ID,它们是准确的。如果这是一个种族问题,我会认为当我尝试重新启动它会起作用,但事实并非如此。最后,没有 TPM 资源管理器。如果是这样的话,我猜 './tpm_device_provision' 会失败。我确实认为这是事实,我过去曾运行过“tpm2_takeowership”,我希望我知道如何重置 TPM——如果有的话。
    【解决方案2】:

    对于其他人来说,似乎正在运行

    tpm2_takeownership -c

    解决了这个问题。

    【讨论】:

      猜你喜欢
      • 2020-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-05
      • 2023-04-06
      • 1970-01-01
      • 2019-10-20
      相关资源
      最近更新 更多