上传公共证书后,customKeyIdentifier值不能用作x5t

时间:2019-05-10 07:39:45

标签: azure certificate azure-active-directory azure-authentication

我试图使用Certificate credentials for application authentication.从Microsoft Azure Active Directory获取JWT令牌,同时在生成JWT令牌时将 customKeyIdentifier 值用作 x5t

有两种创建应用的方法

1) App Registrations(Legacy)
2) App Registrations

enter image description here

从以上两个位置中的任意一个创建应用 test-app-13 之后。 我从下面的两个路径上传了相同的公共证书文件,以获取 customKeyIdentifier

1)AzureActiveDirectory-> AppRegistrations(旧版)-> test-app-13->设置->密钥->上传公共密钥

header = {
"alg": "RS256",
"typ": "JWT",
"x5t": "oO/ImH7U2wcypCvrY+iYalHOOmg="
};

当我使用“ x5t”:“ oO / ImH7U2wcypCvrY + iYalHOOmg =” 时,身份验证有效。

enter image description here

2)AzureActiveDirectory-> AppRegistrations-> test-app-13->证书和机密->上传证书

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"
  }

enter image description here

我的问题是,如果从路径 AzureActiveDirectory-> AppRegistrations-> test-app-13-> Settings->证书和机密->上传证书< / strong> 以及为什么customKeyIdentifier的值与这两个地方的生成方式不同?

1 个答案:

答案 0 :(得分:0)

您引用的两个值相同,try running this hex2base64 on them.

一个是base64编码的oO/ImH7U2wcypCvrY+iYalHOOmg=,另一个是十六进制表示形式A0EFC8987ED4DB0732A42BEB63E8986A51CE3A68I

似乎图形服务仅在对base64进行编码时才支持该值。