我尝试使用 Certificate credentials for application authentication. 从 Microsoft Azure Active Directory 获取 JWT token 我在生成 JWT token 时使用 customKeyIdentifier 值作为 x5t)
有两种创建应用程序的方法
1) App Registrations(Legacy)
2) App Registrations
从上述两个位置中的任何一个创建应用程序test-app-13后。 我从下面两个路径上传了相同的公共(public)证书文件来获取 自定义 key 标识符。
1) AzureActiveDirectory-> AppRegistrations(Legacy) -> test-app-13->设置-> key ->上传公钥
header = {
"alg": "RS256",
"typ": "JWT",
"x5t": "oO/ImH7U2wcypCvrY+iYalHOOmg="
};
当我使用 "x5t": "oO/ImH7U2wcypCvrY+iYalHOOmg=" 时,身份验证有效。
2) AzureActiveDirectory-> AppRegistrations -> test-app-13-> 证书和 secret -> 上传证书
header = {
"alg": "RS256",
"typ": "JWT",
"x5t": "A0EFC8987ED4DB0732A42BEB63E8986A51CE3A68"
};
但是当我使用 "x5t": "A0EFC8987ED4DB0732A42BEB63E8986A51CE3A68" 时,我不断收到错误
{
"error":"invalid_client",
"error_description":"AADSTS700027: Client assertion contains an invalid
signature. [Reason - The key was not found., Thumbprint of key used by
client:
'0341050BCF7CEC40F80C1D3BDF6038D81101EB713CF7CE80E75084DC0EBC', Please
visit 'https://developer.microsoft.com/en-us/graph/graph-explorer'
and query for
'https://graph.microsoft.com/beta/applications/2e452b20-df6d-4228-
83c6-5742b1a8f59c' to see configured keys]\r\nTrace ID: 0a77a624-
684d-4145-9ce5-d19e1b6ccb00\r\nCorrelation ID: 09254eb4-6128-4e18-a
bf6-70b5e9a68960\r\nTimestamp: 2019-05-09 12:39:29Z",
"error_codes":[700027],
"timestamp":"2019-05-09 12:39:29Z",
"trace_id":"0a77a624-684d-4145-9ce5-d19e1b6ccb00",
"correlation_id":"09254eb4-6128-4e18-abf6-70b5e9a68960"
}
.
我的问题是为什么“x5t”:“A0EFC8987ED4DB0732A42BEB63E8986A51CE3A68I”如果从路径上传公共(public)证书则不起作用AzureActiveDirectory-> AppRegistrations -> test-app-13->设置->证书和 secret ->上传证书强> 为什么这两个地方生成的customKeyIdentifier的值不一样?
最佳答案
您引用的两个值是相同的,try running this hex2base64 on them.
一个是base64编码的oO/ImH7U2wcypCvrY+iYalHOOmg=
,另一个是十六进制表示A0EFC8987ED4DB0732A42BEB63E8986A51CE3A68I
。
图形服务似乎仅支持base64编码时的值。
关于azure - 上传公共(public)证书后,customKeyIdentifier 值无法用作 x5t,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56072896/