針對 Azure 中 Windows VM 上的擴充功能憑證問題進行疑難解答
本文討論如何識別及修正在使用擴充功能的 Windows 虛擬機 (VM) 上涉及憑證的問題。 這些問題通常與密碼編譯作業或憑證本身有關。
疑難解答檢查清單
檢視來賓記錄
若要取得錯誤的詳細數據,請檢查來賓記錄。 下表顯示 Windows VM 上針對擴充功能憑證錯誤進行疑難解答最有用的記錄。
記錄 | 描述 |
---|---|
C:\WindowsAzure\Logs\WaAppAgent.log記錄檔 | 客體代理程式記錄檔。 描述擴充功能的作業 (,例如下載、安裝、啟用和停用) 及其結果。 |
C:\WindowsAzure\Logs\Plugins\<ExtensionName> 資料夾中的記錄檔 | 反映特定擴充功能作業的各種記錄。 每個擴充功能都有自己的功能,但大部分的延伸模組都有一組標準的記錄檔,包括 CommandExecution.log、 CommandExecution_<Timestamp>.log、 CustomScriptHandler.log 和 IaaSBcdrExtension<Number>.log。 |
注意事項
此數據表只包含最值得注意的記錄檔。 這不是完整的清單。
或者,您可以執行 CollectGuestLogs.exe 工具,將所有來賓記錄收集到 .zip 封存盤案。 CollectGuestLogs.exe 工具位於下列其中一個目錄的 Windows VM 上:
- C:\WindowsAzure\Packages
- C:\WindowsAzure\GuestAgent_<VersionNumber>_<Timestamp>
徵狀
下列清單概述當您在 Windows VM 上使用擴充功能時,可能發生的最常見錯誤:
FailedToDecryptProtectedSettings
例外狀況:VM 遺漏用來解密擴充功能受保護設定的傳輸憑證。注意事項
例外狀況的
FailedToDecryptProtectedSettings
變體會導致 在 Crypto\RSA\MachineKeys 資料夾上設定不正確的許可權。 在此案例中,會顯示下列其中一個錯誤訊息:System.Security.Cryptography.CryptographicException: Keyset does not exist at System.Security.Cryptography.Pkcs.EnvelopedCms.DecryptContent(RecipientInfoCollection recipientInfos, X509Certificate2Collection extraStore) at Microsoft.Azure.Plugins.Diagnostics.dll.PluginConfigurationSettingsProvider.DecryptPrivateConfig(String encryptedConfig)
Failed to decode, decrypt, and deserialize the protected settings string. Error Message: Keyset does not exist"
Decrypting Protected Settings - Invalid provider type specified
[ERROR] Failed to get TransportCertificate. Error: Microsoft.WindowsAzure.GuestAgent.CertificateManager.CryptographyNative+PInvokeException: Self-signed Certificate Generation failed. Error Code: -2146893808.
「無法擷取憑證」錯誤訊息。
CryptographicException
VM 診斷設定中的例外狀況,伴隨訊息「信封數據訊息不包含指定的收件者」。下列文字描述此例外狀況的範例:DiagnosticsPluginLauncher.exe Information: 0 : [6/29/2020 1:32:20 PM] Decrypting private configuration DiagnosticsPluginLauncher.exe Warning: 0 : [6/29/2020 1:32:20 PM] No certficate with given thumbprint found in the certificate store. Thumbprint:34C8CDC747693E0E33A9648703E3990EC4F2C484 DiagnosticsPluginLauncher.exe Information: 0 : [6/29/2020 1:32:20 PM] Retrying after 30 seconds. Retry attempt 1 DiagnosticsPluginLauncher.exe Warning: 0 : [6/29/2020 1:32:50 PM] No certficate with given thumbprint found in the certificate store. Thumbprint:34C8CDC747693E0E33A9648703E3990EC4F2C484 DiagnosticsPluginLauncher.exe Information: 0 : [6/29/2020 1:32:50 PM] Retrying after 30 seconds. Retry attempt 2 DiagnosticsPluginLauncher.exe Warning: 0 : [6/29/2020 1:33:20 PM] No certficate with given thumbprint found in the certificate store. Thumbprint:34C8CDC747693E0E33A9648703E3990EC4F2C484 DiagnosticsPluginLauncher.exe Information: 0 : [6/29/2020 1:33:20 PM] Retrying after 30 seconds. Retry attempt 3 DiagnosticsPluginLauncher.exe Error: 0 : [6/29/2020 1:33:50 PM] System.Security.Cryptography.CryptographicException: The enveloped-data message does not contain the specified recipient. at System.Security.Cryptography.Pkcs.EnvelopedCms.DecryptContent(RecipientInfoCollection recipientInfos, X509Certificate2Collection extraStore) at Microsoft.Azure.Plugins.Diagnostics.dll.PluginConfigurationSettingsProvider.DecryptPrivateConfig(String encryptedConfig)
推送至 VM 但會干擾其他作業的新憑證。
原因:工作流程和相依性程式代碼變更
此問題主要是由於 Azure 平臺在 2020 年 5 月前後實作的變更所造成。 這項變更是為了改善 VM 擴充功能的工作流程,並消除其他 Azure 元件的一些相依性。 它需要擴充功能、自定義資源提供者 (CRP) ,客體代理程式才能共同運作。 次要錯誤導致次要問題反映在擴充功能憑證問題中。
解決方案 1:更新延伸模組憑證
請遵循下列步驟來更新可與擴充功能一起成功使用的憑證:
檢查 Windows Azure CRP 憑證產生器 憑證是否包含在 Microsoft Management Console 的 [憑證] 嵌入式管理單元中。 若要這樣做,請遵循使用擴充功能在 Azure IaaS VM 上使用多個憑證 中的指示來尋找 Windows VM 徵兆。
刪除該憑證。 若要這樣做,請選取 Windows Azure CRP 憑證產生器 憑證,然後選取 [刪除] 圖示。
注意事項
需要 Windows Azure CRP 憑證產生器 憑證時,VM 會在遺失憑證時重新建立憑證。
套用下列其中一個選項,以觸發客體代理程式的新目標狀態:
執行下列包含 Get-AzureRmVM 和 Update-AzureRmVM 命令的 PowerShell 腳本:
$rg = "<name-of-the-resource-group-containing-the-virtual-machine>" $vmName = "<name-of-the-virtual-machine>" $vm = Get-AzureRmVM -ResourceGroupName $rg -Name $vmName Update-AzureRmVM -ResourceGroupName $rg -VM $vm
依照虛擬 機停滯在失敗狀態 一文中一節中的指示,在您的 VM 上執行「重新套用」作業。
重試擴充功能作業。
如果憑證更新未修正此問題,請停止或解除分配 VM,然後再次啟動 VM。
解決方案 2:修正 MachineKeys 或 SystemKeys 資料夾中 ACL) (存取控制清單
在 Crypto\RSA\MachineKeys 資料夾中,修正 ACL) (存取控制清單,以便套用正確的許可權。
在系統管理 PowerShell 控制台中,執行下列命令以取得租用戶憑證的唯一密鑰容器名稱。 請務必
$certName
根據您使用的是憑證名稱) 的傳統 RedDog 前端 (RDFE) VM (或憑證名稱Windows Azure Service Management for Extensions
Windows Azure CRP Certificate Generator
) 的 Azure Resource Manager VM (,將其中一個定義批注化:# Comment out one of the following certificate name definitions. $certName = "Windows Azure Service Management for Extensions" # Classic RDFE VM $certName = "Windows Azure CRP Certificate Generator" # Azure Resource Manager VM $fileName = (Get-ChildItem Cert:\LocalMachine\My | Where-Object {$_.Subject -eq 'DC=$certName'} ).PrivateKey.CspKeyContainerInfo.UniqueKeyContainerName
執行 icacls 命令來備份 ACL:
icacls C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys /save machinekeys_permissions_before.aclfile /t
執行下列
icacls
命令來更正 MachineKeys 權限:icacls C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys\$fileName /grant SYSTEM:(F) icacls C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys\$fileName /grant Administrators:(RX)
再次執行
icacls
,將更新的 MachineKeys ACL 重新導向至文字檔:icacls C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys /t > machinekeys_permissions_after.txt
在文本編輯器中檢視 machinekeys_permissions_after.txt 檔案,以確認許可權變更是否如預期般顯示。
請再試一次擴充功能,或執行 WaAppAgent.exe或WindowsAzureGuestAgent.exe 工具來嘗試重新啟動客體代理程序服務。
如果此程式無法運作,您可以嘗試 icacls
再次執行命令, (C:\ProgramData\Microsoft\Crypto\SystemKeys\* 通配符資料夾上的步驟 2-4) ,而不是 C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys\$fileName 資料夾。
其他相關資訊
與我們連絡,以取得說明
如果您有問題或需要相關協助,請建立支援要求,或詢問 Azure community 支援。 您也可以將產品意見反應提交給 Azure 意應見反社群。
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應