-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ConfidentialClientApplication.AcquireTokenForClient fails with Microsoft.Identity.Client.MsalClientException: MSAL V3 Deserialization failed #3162
Comments
Understood, so it looks like we should try to acquire a new token if we are unable to read the bytes from the cache since they key used may have been rotated. Any idea what the implications of doing this will be @bgavrilMS, @pmaytak? |
We will need to look at this in more detail. In the L1/L2 cache, the L2 cache operations are already set to fail silently. However, the encryption occurs in this base class, no tin the L1/L2 class. I also wonder if the ASP.NET Core data protection infrastructure doesn't take this case into account. |
CC @jennyf19 for an opinion |
@fahd-ms Specifically for the issue related to key encryption certificates, Data Protection API has UnprotectKeysWithAnyCertificate method that can accept new and old certs. Have you tried this? |
Thanks @pmaytak - I'll try this out. |
@fahd-ms Were you able to try it out, did it help? |
Closing, please reopen if issue is not resolved. Not much can be done on MSAL.NET side; encryption must be correctly set up user-side. Microsoft Identity Web will have a better exception and logging in 1.23.1. Scenario documented in https://aka.ms/ms-id-web/token-cache-troubleshooting. |
released in 1.23.1 |
Logs and network traces
Without logs or traces, it is unlikely that the team can investigate your issue. Capturing logs and network traces is described in Logging wiki.
Which version of MSAL.NET are you using?
MSAL.NET 4.40.0.0
Platform
.NET 4.7
What authentication flow has the issue?
Other?
Using token cache serialization from
Microsoft.Identity.Web.TokenCache 1.22.1
AddDistributedTokenCache
methodMsalDistributedTokenCacheAdapterOptions
hasEncrypt=true
ProtectKeysWithCertificate
and shared via RedisLooking at the stack trace (attached file) and the code, it looks like
DeserializeMsalV3
fails whenUnprotectBytes
is unable to decrypt the token in Microsoft.Identity.Web.TokenCache, it still tries to deserialize encrypted token and fails as that is not a valid json string. Link to code:https://github.com/AzureAD/microsoft-identity-web/blob/d26e79ddf9fdd2e1fa740711ec652cb2a221fc1f/src/Microsoft.Identity.Web.TokenCache/MsalAbstractTokenCacheProvider.cs#L101
https://github.com/AzureAD/microsoft-identity-web/blob/d26e79ddf9fdd2e1fa740711ec652cb2a221fc1f/src/Microsoft.Identity.Web.TokenCache/MsalAbstractTokenCacheProvider.cs#L105-L121
stack trace
Is this a new or existing app?
a. The app is in production, and I have upgraded to a new version of MSAL and the DataProtectionCertificate was rotated.
Repro
Expected behavior
AcquireTokenForClient
should not fail on L1/L2 cache read and/or write failure and should return access token directly from AAD.Actual behavior
AcquireTokenForClient
fails withMSALClientException MSAL V3 Deserialization failed
.stack trace
The text was updated successfully, but these errors were encountered: