Base solution for your next web application
Open Closed

An exception was thrown while deserializing the token after performing Slot Swap (Clustered Deployment) #12345


User avatar
0
ricardo created

*Aspnet Core MVC
*Last Version
*Azure App Service

Hi,

After changing slots (staging -> Production), users logged into Production are disconnected and the logs show the error below:

spNetCore.Antiforgery.DefaultAntiforgery - An exception was thrown while deserializing the token.
Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: The antiforgery token could not be decrypted.
---> System.Security.Cryptography.CryptographicException: The key {965441a2-128b-4680-922e-aa50c6196f7a} was not found in the key ring. For more information go to https://aka.ms/aspnet/dataprotectionwarning
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte[] protectedData, Boolean allowOperationsOnRevokedKeys, UnprotectStatus& status)
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect(Byte[] protectedData)
at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgeryTokenSerializer.Deserialize(String serializedToken)
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgeryTokenSerializer.Deserialize(String serializedToken)
at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery.GetCookieTokenDoesNotThrow(HttpContext httpContext)

*we are publishing in a windows environment on azure with 3 allocated instances, Cache Redis, signalr backplane and Hangfire.

I came across this article: https://aspnetzero.com/blog/persist-data-protection-keys-to-database

Is this type of implementation still necessary or is it standard from Zero?

tanks.


5 Answer(s)