microsoft-authentication-library-for-dotnet: Access Token Signature validation fails
Which Version of MSAL are you using ? 2.7.0
Which platform has the issue? .NET 4.6 / Win 10 1809
What authentication flow has the issue?
- Desktop / Mobile
- Interactive
Repro
var Application = new PublicClientApplication(
ClientId,
"https://login.microsoftonline.com/organizations/");
var account = await Application.GetAccountsAsync()).FirstOrDefault();
var scopes = new[] { "user.read" };
var result = await Application.AcquireTokenAsync(scopes).ConfigureAwait(false);
var accessToken = result.AccessToken;
- Provide a
ClientIdvalue, put breakpoint to the last line, run the code and sign in to Azure. - Grab the
accessTokenvalue and put it into theEncodedfield at https://jwt.io/ - Write down the
kidvalue shown in theDecode/headerfield. Note: The tested tokens usedRS256algorithm. - Open https://login.windows.net/common/discovery/keys, find the
kidvalue and grab the appropriatex5cstring value. - Open a new file (call it
cert.cer) and write in it
-----BEGIN CERTIFICATE-----
the grabbed x5c string value
-----END CERTIFICATE-----
-
Run
openssl x509 -pubkey -in cert.cer -text -nooutcommand and grab the public key-----BEGIN PUBLIC KEY … END PUBLIC KEY----- -
Paste the public key into the
VERIFY SIGNATURE/Public keyfield on the already opened https://jwt.io/ -
Notice that it show
invalid signaturebellow theEncodedfield.
The token was also tested using PHP openssl extension (via this, this and this library chain) and it also fails signature verification.
Expected behavior The signature verification succeeds and the signature is considered valid.
Actual behavior The signature verification fails that the signature is considered invalid.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 25 (12 by maintainers)
Thanks @jmprieur, you helped a lot.
@mcetkovsky is there a ‘nonce’ in the JwtHeader?