在 Azure AD 应用程序集成期间无法添加证书

Unable to add certificate during Azure AD app integration

我在尝试添加证书时遇到以下错误,它是我正在集成的 Azure AD 应用程序的文件名 cert.pem:

添加证书失败。错误详细信息:上传具有以下文件类型之一的证书(public 密钥):.cer、.pem、.crt

我确定即使文件类型正确 (.pem),但文件的结构和内容不正确,但我不知道如何修复它。

如您所说,文件内容不正确。您可以使用带有 New-SelfSignedCertificate. Try to refer to here 的 PowerShell 创建用于测试目的的证书。确保以管理员帐户打开 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())