我正在尝试从azure powershell自动化帐户中存储在azure keyvualt中的pem和密钥文件生成pfx。我可以使用openssl生成具有相同密钥和pem文件的pfx,但是当我在powershell中尝试相同的操作时,出现错误“ Convert-PemToPfx:异常设置” PrivateKey”:“证书的公钥与值 指定。”
$secretpem = Get-AzureKeyVaultSecret -VaultName '$vaultname' -Name 'secret-pem'
$secretkey = Get-AzureKeyVaultSecret -VaultName '$vaultname' -Name 'secret-key'
$pem = "certificate.pem"
$secretpem.SecretValueText | Out-File -FilePath $pem
$key = "certificate.key"
$secretkey.SecretValueText | Out-File -FilePath $key
$password = ConvertTo-SecureString "P@ssW0rD!" -asplaintext -for
#Get-Content -Path certificate.pem
#Get-Content -Path certificate.key
Import-Module -Name PSPKI
Convert-PemToPfx -InputPath certificate.pem -KeyPath certificate.key -OutputPath certificate.pfx -
Password $password