Azure错误“您的证书文件无效或密码不正确”将证书加载到门户中

时间:2018-09-16 03:53:42

标签: azure-keyvault

我通过xero instructions生成了public_privatekey.pfx,并且能够从使用Xerp.Api.Sdk.Core的Visual Studio解决方案中访问Xero演示文件

现在,我要将证书放入Azure密钥保管库中,以便将代码移植到Azure Function App。

但是,当我尝试使用Azure门户通过

加载证书时

创建秘密->证书->创建证书

我收到错误

Your certificate file was invalid, or the password was incorrect

我可以使用Powershell加载证书。

Connect-AzureRmAccount -tenantid mytenantid
$pfxFilePath = 'C:\OpenSSL-Win64\bin\AzureXeroSync\public_privatekey.pfx'
$pwd = 'mypassword'
$flag = [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable
$collection = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2Collection 
$collection.Import($pfxFilePath, $pwd, $flag)
$pkcs12ContentType = [System.Security.Cryptography.X509Certificates.X509ContentType]::Pkcs12
$clearBytes = $collection.Export($pkcs12ContentType)
$fileContentEncoded = [System.Convert]::ToBase64String($clearBytes)
$secret = ConvertTo-SecureString -String $fileContentEncoded -AsPlainText –Force
$secretContentType = 'application/x-pkcs12'
Set-AzureKeyVaultSecret -VaultName 'MyAzureFunctionsVault' -Name 'XeroPfxSecret' -SecretValue $Secret -ContentType $secretContentType

使用门户网站时我缺少什么?

1 个答案:

答案 0 :(得分:0)

您在问题中提到了这一点:

  

创建秘密->证书->创建证书

enter image description here

我认为这里的问题是您从“创建秘密”开始。如您在屏幕快照中看到的那样,将证书作为秘密上载/导入是不推荐使用的功能。

您可以尝试做同样的事情,但是要从“证书”开始,然后再导入吗?

enter image description here

enter image description here

enter image description here

相关问题