C# 新AzureADApplicationKeyCredential double base64是否为CustomKeyIdentifier和Value编码?
我正在使用新的AzureADApplicationKeyCredential为应用程序创建KeyCredential 首先,我对指纹进行base64编码C# 新AzureADApplicationKeyCredential double base64是否为CustomKeyIdentifier和Value编码?,c#,azure,powershell,azure-active-directory,C#,Azure,Powershell,Azure Active Directory,我正在使用新的AzureADApplicationKeyCredential为应用程序创建KeyCredential 首先,我对指纹进行base64编码 $cer = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 $cer.Import("C:\Users\PFuller\Desktop\abc.cer") ... $bin = $cer.GetCertHash() $base64Thumbp
$cer = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$cer.Import("C:\Users\PFuller\Desktop\abc.cer")
...
$bin = $cer.GetCertHash()
$base64Thumbprint = [System.Convert]::ToBase64String($bin)
...
New-AzureADApplicationKeyCredential -ObjectId <id>
-CustomKeyIdentifier $base64Thumbprint
-Type AsymmetricX509Cert
-Usage Verify -Value $base64Value
据
customKeyIdentifier只应base64编码一次,并存储在清单的keyCredentials上
我是不是误用了这个命令或者这里出了什么问题?因为在我将清单转换为base64编码一次之后,一切都正常工作
谢谢您的帮助。根据我的测试,当我们使用
新建AzureADApplicationKeyCredential
为应用程序创建KeyCredential时,customKeyIdentifier
和value
都是双基64编码的
之后,我使用以下代码获取此证书的访问令牌:
var app = ConfidentialClientApplicationBuilder.Create("{clientId}")
.WithAuthority(AzureCloudInstance.AzurePublic, "{tenantId}")
.WithCertificate(cer)
.Build();
var result = await app.AcquireTokenForClient(new[] { "https://graph.microsoft.com/.default" }).ExecuteAsync();
Console.WriteLine(result.AccessToken);
我发现我们可以成功地获得具有正确角色的访问令牌
因此,我认为新AzureADApplicationKeyCredentialbase64将
customKeyIdentifier
和value
编码到另一个时间。但是,当我们使用X509Certificate获取访问令牌时,它也能正确地处理它们。Hi,我的回答有用吗?如果您那边有任何更新,请让我知道:)谢谢,很抱歉反应太晚。在我的测试中,无论customKeyIdentifier是Base64编码一次还是两次。使用相同的customKeyIdentifier组合JWT,两者都可以从客户端\u凭据流获取访问令牌。
var app = ConfidentialClientApplicationBuilder.Create("{clientId}")
.WithAuthority(AzureCloudInstance.AzurePublic, "{tenantId}")
.WithCertificate(cer)
.Build();
var result = await app.AcquireTokenForClient(new[] { "https://graph.microsoft.com/.default" }).ExecuteAsync();
Console.WriteLine(result.AccessToken);