【发布时间】:2021-02-04 18:34:12
【问题描述】:
我正在尝试使用 Add-AzKeyVaultKey 将密钥添加到密钥库,但失败并显示消息“指定的提供程序类型无效”。
Add-AzKeyVaultKey : Invalid provider type specified.
At line:3 char:1
+ Add-AzKeyVaultKey -VaultName '$KeyVaultName' -Name 'alfalaval-as2-pri ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Add-AzKeyVaultKey], CryptographicException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.KeyVault.AddAzureKeyVaultKey
我可以成功地将证书(从 pfx)导入到 keyvault,但是从同一个 pfx 导入密钥时操作失败。
根据微软文档,应该是pfx文件(不支持PEM):Micsosoft, Add-AzKeyVaultKey
如果有人想试用,我已在此处 (keypair at filebin) 上传了一个示例虚拟密钥对。
示例代码
#Import certificate used for encryption
$Password = ConvertTo-SecureString -String "abcd1234" -AsPlainText -Force
Import-AzKeyVaultCertificate -VaultName "$KeyVaultName" -Name "as2-demo-certificate" -FilePath 'C:\mypath\as2-demo-cert.pfx' -Password $Password
#Importing key used for decryption
Add-AzKeyVaultKey -VaultName '$KeyVaultName' -Name 'as2-demo-private-key' -Destination 'Software' -KeyFilePath 'C:\mypath\as2-demo-cert.pfx' -KeyFilePassword $Password
任何帮助表示赞赏:)
【问题讨论】:
-
this 有帮助吗?
-
是的,谢谢 - 成功了。我在从 powershell 生成证书时指定了提供程序。
-
太棒了!很高兴听到它修复了。为了他人的利益,请考虑发布一个自我回答来解释更多关于此的内容。
-
当然! :) 谢谢
标签: powershell import key azure-keyvault