为什么jwt.io网站出现验证令牌的错误?
我从Microsoft Identity平台获得了访问令牌,并尝试使用JWT.IO网站验证其签名(以了解验证过程)。事实是,当我将此访问令牌粘贴到JWT.IO网站上并在«  public键'»上粘贴公共密钥box,jwt.io仍在返回错误,表明签名无效。 我使用的公共密钥由Microsoft Identity使用«  kid»»提供。宣称。更确切地说,我将公开密钥与«  - - 开始证书 - -  »包裹起来。和«  - End证书 - - »并将其全部粘贴到公共密钥框中。 (顺便说一句,在私钥盒上,我什么也没放) 我在做什么错? 感谢您的所有帮助。
I get an access token from Microsoft Identity Platform and I try to verify its signature (to understand the process of validation) using jwt.io website. The thing is when I paste this access token on jwt.io website and paste the public key on the « public key » box, jwt.io is still returning an error, stating the signature is invalid.
The public key I am using is given by Microsoft Identity using the « kid » claim. To be more precise I take the public key and wrap it with « ——BEGIN CERTIFICATE—- » and « —-END CERTIFICATE—- » and paste it all on the public key box. ( By the way, on the private key box I put nothing)
What am I doing wrong ?
Thank you for all your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是从我的Azure AD开发帐户中与之相比的工作手册JWT验证。希望这使您能够解决自己的问题,并且还突出了许多API安全库的步骤:
JWT访问令牌
jwt Header的儿童价值
2ZQPJ3UPBJAXYXYXYXYXYGAXEJL8L8L8L8LV0TOI
JWKS URI JWKS URI JWKS URI <> /strong>
从这里下载包含令牌签名公共键的JSON Web Keyset:
https://login.microsoftonline.com/7f071fbc-8bf2-4e61-bb48-dabd8e2f5b5a/discovery/discovery/v2.0/keys/keys 是匹配
kid
的密钥集中的项目JWT标头的字段。您可以将此JSON粘贴到JWT.IO的公共密钥文本字段中,JWT将通过验证:令牌签名公共密钥(PEM格式)
您可以使用a jwk to pem converter 转换JWK到PEM格式。您可以将此证书文本粘贴到JWT.IO的公共密钥文本字段中,JWT也将通过验证:
Here is a working manual JWT validation to compare against, from my Azure AD development account. Hopefully this enables you to solve your own problem, and also highlights the steps many API security libraries follow:
JWT ACCESS TOKEN
KID VALUE FROM JWT HEADER
2ZQpJ3UpbjAYXYGaXEJl8lV0TOI
JWKS URI
The JSON Web Keyset containing token signing public keys is downloaded from here:
https://login.microsoftonline.com/7f071fbc-8bf2-4e61-bb48-dabd8e2f5b5a/discovery/v2.0/keys
TOKEN SIGNING PUBLIC KEY (JWK FORMAT)
This is the item in the keyset that matches the
kid
field from the JWT header. You can paste this JSON into the public key text field in jwt.io and the JWT will pass validation:TOKEN SIGNING PUBLIC KEY (PEM FORMAT)
You can use a JWK to PEM converter to convert the JWK to PEM format. You can paste this certificate text into the public key text field in jwt.io and the JWT will also pass validation:
所以我不知道发生了什么,但是当我停止填充钥匙盒时,jwt.io终于自行验证了令牌...所以也许jwt.io自动检测到令牌作为Microsoft Azure签名的令牌,并在公共密钥上检索了公共密钥它自己的。非常感谢您四个帮助
so I dont know what happened but when I stopped filling the key boxes, jwt.io finally validated the token on its own... so maybe jwt.io detected automatically the token as a token signed by Microsoft Azure and retrieved the public key on its own. Thanks a lot you all four help