如何使用 Powershell 通过证书 SNI 获取 azure AAD 令牌

问题描述 投票:0回答:0

我正在尝试使用 powershell 通过证书 SNI 获取 AAD 令牌。

我可以使用下面的代码通过证书指纹获取令牌,但它不适用于使用证书 SNI 注册的应用程序:

$certBase64 = Get-AzKeyVaultSecret -VaultName $keyvaultName -Name $certName -AsPlainText
$certificate = [System.Convert]::FromBase64String($certBase64)
$context = [Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext]::new($authUri) 
$clientAssertion = [Microsoft.IdentityModel.Clients.ActiveDirectory.ClientAssertionCertificate]::new($AppId,$certificate)
$ResourceId = "https://management.azure.com/"
$tokenResponse = $context.AcquireTokenAsync($ResourceId, $clientAssertion)

有什么建议吗?

azure azure-active-directory azure-powershell
© www.soinside.com 2019 - 2024. All rights reserved.