【发布时间】:2021-07-20 05:29:58
【问题描述】:
我在尝试为我正在集成的 Azure AD 应用添加证书(文件名 cert.pem)时遇到以下错误:
添加证书失败。错误详情:上传具有以下文件类型之一的证书(公钥):.cer、.pem、.crt
我确信即使文件类型正确(.pem)文件的结构和内容也不正确,但我不知道如何修复它。
【问题讨论】:
标签: azure-active-directory certificate x509 pem
我在尝试为我正在集成的 Azure AD 应用添加证书(文件名 cert.pem)时遇到以下错误:
添加证书失败。错误详情:上传具有以下文件类型之一的证书(公钥):.cer、.pem、.crt
我确信即使文件类型正确(.pem)文件的结构和内容也不正确,但我不知道如何修复它。
【问题讨论】:
标签: azure-active-directory certificate x509 pem
如您所说,文件内容不正确。您可以使用带有New-SelfSignedCertificate 的PowerShell 创建用于测试目的的证书。尝试参考here。确保以管理员帐户打开 PowerShell。
$pwd = "<password>"
$currentDate = Get-Date
$endDate = $currentDate.AddYears(10) #10 years is nice and long
$thumb = (New-SelfSignedCertificate -DnsName "techmikael.com" -CertStoreLocation "cert:\LocalMachine\My" -KeyExportPolicy Exportable -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" -NotAfter $endDate).Thumbprint
$pwd = ConvertTo-SecureString -String $pwd -Force -AsPlainText
Export-PfxCertificate -cert "cert:\localmachine\my\$thumb" -FilePath .\techmikael.pfx -Password $pwd
$path = (Get-Item -Path ".\").FullName
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate("$path\techmikael.pfx", $pwd)
$keyValue = [System.Convert]::ToBase64String($cert.GetRawCertData())
【讨论】: