Azure IoT 操作对其 docker 和 helm 映像进行签名,以允许用户验证其使用的映像的完整性和来源。 签名利用公钥/私钥对来创建数字签名并将其添加到映像中,以证明 Microsoft 构建了容器映像。 本文提供了验证映像是否由 Microsoft 签名的步骤。
下载 Notation。
export NOTATION_VERSION=1.1.0 curl -LO https://github.com/notaryproject/notation/releases/download/v$NOTATION_VERSION/notation_$NOTATION_VERSION\_linux_amd64.tar.gz sudo tar xvzf notation_1.1.0_linux_amd64.tar.gz -C /usr/bin/ notation
下载 Microsoft 签名公共证书:
https://www.microsoft.com/pkiops/certs/Microsoft%20Supply%20Chain%20RSA%20Root%20CA%202022.crt
。确保保存为
msft_signing_cert.crt
。将证书添加到 notation cli 中。
notation cert add --type ca --store supplychain msft_signing_cert.crt
检查 notation 中的证书。
notation cert ls
该命令的输出如下例所示:
STORE TYPE STORE NAME CERTIFICATE ca supplychain msft_signing_cert.crt
使用映像范围创建 trustpolicy 文件。
{ "version": "1.0", "trustPolicies": [ { "name": "supplychain", "registryScopes": [ "*" ], "signatureVerification": { "level" : "strict" }, "trustStores": [ "ca:supplychain" ], "trustedIdentities": [ "x509.subject: CN=Azure IoT Operations,O=Microsoft Corporation,L=Redmond,ST=Washington,C=US", "x509.subject: CN=Microsoft SCD Products RSA Signing,O=Microsoft Corporation,L=Redmond,ST=Washington,C=US" ] } ] }
- 我们允许所有 registryScopes,以避免列出与 Azure IoT 操作捆绑的每个映像,并防止将来需要进行更改。
-
CN=Azure IoT Operations
涵盖所有 Azure IoT 操作映像。 但是,其他 Microsoft 映像需要CN=Microsoft SCD Products RSA Signing
。
使用表示法根据信任策略验证下载的映像。
将版本占位符替换为要检查的映像的版本号。 对于 Azure IoT 操作的现有实例,可以在 Azure 门户中的实例概述页上查找版本号,也可以通过运行 az iot ops show 来查找版本号。 有关可用版本的完整列表,请参阅 azure-iot-operations 版本。
notation policy import <TRUSTPOLICY_FILE>.json export NOTATION_EXPERIMENTAL=1 notation verify --allow-referrers-api mcr.microsoft.com/azureiotoperations/aio-operator:<AZURE_IOT_OPERATIONS_VERSION>
该命令的输出如下例所示:
Successfully verified signature for mcr.microsoft.com/azureiotoperations/aio-operator@sha256:09cbca56a2149d624cdc4ec952abe9a92ee88c347790c6657e3dd2a0fcc12d10