我通过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
使用门户网站时我缺少什么?