View a markdown version of this page

使用 AMD SEV-SNP 來認證 Amazon EC2 執行個體 - Amazon Elastic Compute Cloud

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

使用 AMD SEV-SNP 來認證 Amazon EC2 執行個體

認證是一種程序,可讓您的執行個體證明其狀態和身分。當您為執行個體啟用 AMD SEV-SNP 後,可以向基礎處理器請求 AMD SEV-SNP 認證報告。AMD SEV-SNP 認證報告包含初始訪客記憶體內容的密碼編譯雜湊 (稱為啟動測量) 和初始 vCPU 狀態。認證報告會使用 VCEK 簽章 (在專用主機上) 或 VLEK 簽章 (在共用租用上) 簽署,該簽章會鏈結回信任的 AMD 根目錄。您可以使用認證報告中包含的啟動測量來驗證執行個體是否在正版 AMD 環境中執行,並驗證用於啟動執行個體的初始啟動程式碼。

先決條件

啟動已為 AMD SEV-SNP 啟用的執行個體。如需詳細資訊,請參閱為 EC2 執行個體啟用 AMD SEV-SNP

專用主機上執行個體的證明

專用主機使用版本化晶片背書金鑰 (VCEK),這是一種唯一的每個晶片簽署金鑰,用於簽署證明報告。您必須驗證從 VCEK 憑證到 AMD 信任根的信任鏈。

注意

目前支援的處理器模型為 milan

先決條件

在已啟用 AMD SEV-SNP 且已安裝 Git、Cargo 和 Perl 的專用主機上執行的執行個體。

步驟 1:建置 snpguest 公用程式

在此步驟中,您會安裝並建置snpguest公用程式,用來產生證明文件報告、擷取所需的憑證,以及驗證證明文件報告。

  1. 連線到您的執行個體。

  2. 驗證是否已安裝先決條件。

    $ perl --version; cargo --version; git --version
  3. 執行下列命令以從 snpguest repository 建置 snpguest 公用程式。

    $ git clone https://github.com/virtee/snpguest.git $ cd snpguest $ cargo build -r $ cd target/release

步驟 2:產生認證報告

產生要求認證報告的請求。snpguest 公用程式會透過主機向 AMD 安全處理器請求認證報告,並將其寫入二進位檔案。下列範例會建立隨機請求 nonce,並將報告存放在 中report.bin

$ ./snpguest report report.bin request-file.txt --random

步驟 3:擷取並驗證 VCEK 憑證鏈

認證報告由 VCEK 簽署,該 VCEK 是您專用主機上 AMD 晶片獨有的。您必須驗證從 VCEK 到 AMD 信任根的信任鏈。

  1. 從 AMD Key Distribution Service (KDS) 擷取 VCEK 憑證。憑證由證明報告中的晶片 ID 和 TCB 版本識別。

    $ ./snpguest fetch vcek pem ./ ./report.bin --processor-model milan
  2. 擷取構成信任鏈的 AMD 根憑證 (AMD 根金鑰 (ARK) 和 AMD SEV 金鑰 (ASK))。

    $ ./snpguest fetch ca PEM ./ milan --endorser vcek
  3. 驗證憑證鏈。

    $ ./snpguest verify certs ./

    以下為範例輸出。

    The AMD ARK was self-signed! The AMD ASK was signed by the AMD ARK! The VCEK was signed by the AMD ASK!

選用:為了提高透明度,您可以直接從 AMD 下載憑證並使用 來獨立驗證鏈openssl

$ curl --proto '=https' --tlsv1.2 -sSf https://kdsintf.amd.com/vcek/v1/Milan/cert_chain -o ./cert_chain.pem $ openssl verify --CAfile ./cert_chain.pem vcek.pem

以下為範例輸出。

vcek.pem: OK

步驟 4:驗證證明報告簽章

確認認證報告已由 VCEK 憑證簽署。這可確認報告是在正版 AMD 硬體上產生,且未遭到篡改。

$ ./snpguest verify attestation ./ report.bin

以下為範例輸出。

Reported TCB Boot Loader from certificate matches the attestation report. Reported TCB TEE from certificate matches the attestation report. Reported TCB SNP from certificate matches the attestation report. Reported TCB Microcode from certificate matches the attestation report. VEK signed the Attestation Report!

TCB (可信運算基礎) 版本欄位會確認憑證中的韌體版本符合認證報告中報告的韌體版本。最後一行確認 VCEK 已簽署報告。

共用租用上執行個體的證明

共用租用執行個體使用由 AMD 發行的版本載入背書金鑰 (VLEK) AWS。您必須驗證從 VLEK 憑證到 AMD 信任根的信任鏈。

步驟 1:建置 snpguest 公用程式

在此步驟中,您會安裝並建置snpguest公用程式,用來產生證明文件報告、擷取所需的憑證,以及驗證證明文件報告。

  1. 連線到您的執行個體。

  2. 執行下列命令以從 snpguest repository 建置 snpguest 公用程式。

    $ git clone https://github.com/virtee/snpguest.git $ cd snpguest $ cargo build -r $ cd target/release

步驟 2:產生認證報告

產生要求認證報告的請求。snpguest 公用程式會從主機請求認證報告,並將其寫入二進位檔案。下列範例會建立隨機請求 nonce,並將報告存放在 中report.bin

$ ./snpguest report report.bin request-file.txt --random

從主機記憶體請求憑證,並將其儲存為 PEM 檔案。

$ ./snpguest certificates PEM ./

步驟 3:擷取並驗證 VLEK 憑證鏈

證明文件報告由 AMD 發行的 VLEK 簽署 AWS。您必須驗證從 VLEK 到 AMD 信任根的信任鏈。

  1. 從官方 AMD Key Distribution Service 下載信任憑證的 VLEK 根目錄到目前的目錄。

    $ sudo curl --proto '=https' --tlsv1.2 -sSf https://kdsintf.amd.com/vlek/v1/Milan/cert_chain -o ./cert_chain.pem
  2. 使用 openssl 來驗證 VLEK 憑證是否由 AMD 信任根憑證簽署。

    $ sudo openssl verify --CAfile ./cert_chain.pem vlek.pem

    以下為範例輸出。

    vlek.pem: OK

步驟 4:驗證證明報告簽章

確認證明報告已由 VLEK 憑證簽署。這可確認報告是在正版 AMD 硬體上產生,且未遭到篡改。

$ ./snpguest verify attestation ./ report.bin

以下為範例輸出。

Reported TCB Boot Loader from certificate matches the attestation report. Reported TCB TEE from certificate matches the attestation report. Reported TCB SNP from certificate matches the attestation report. Reported TCB Microcode from certificate matches the attestation report. VEK signed the Attestation Report!