Base solution for your next web application
Open Closed

ValidateAntiforgeryTokenAuthorizationFilter - The antiforgery token could not be decrypted. #9731


User avatar
0
trungbttsd created

Hi, I am using Zero ASP.NET Core MVC & jQuery Project v9.0.1

I have other problems, when accessing the functions of one.vn/hrm then encountered an authentication token error

logs.txt:

ERROR 2020-10-20 11:17:54,554 [18 ] idateAntiforgeryTokenAuthorizationFilter - The antiforgery token could not be decrypted. Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: The antiforgery token could not be decrypted. ---> System.Security.Cryptography.CryptographicException: The key {cae636c4-afc9-4d7b-9e9e-de33f4e11c88} was not found in the key ring. at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte[] protectedData, Boolean allowOperationsOnRevokedKeys, UnprotectStatus& status) at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.DangerousUnprotect(Byte[] protectedData, Boolean ignoreRevocationErrors, Boolean& requiresMigration, Boolean& wasRevoked) 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.DeserializeTokens(HttpContext httpContext, AntiforgeryTokenSet antiforgeryTokenSet, AntiforgeryToken& cookieToken, AntiforgeryToken& requestToken) at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery.ValidateTokens(HttpContext httpContext, AntiforgeryTokenSet antiforgeryTokenSet) at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery.ValidateRequestAsync(HttpContext httpContext) at Abp.AspNetCore.Mvc.Antiforgery.AbpValidateAntiforgeryTokenAuthorizationFilter.OnAuthorizationAsync(AuthorizationFilterContext context) ERROR 2020-10-20 11:18:08,692 [20 ] e.Diagnostics.ExceptionHandlerMiddleware - An unhandled exception has occurred while executing the request.

When I click on any function:

Error:

Help me pls, Tks!


2 Answer(s)
  • User Avatar
    0
    trungbttsd created

    At first, I got an error related to the unauthenticated loggin, I know the reason is the same cookie of one.vn/hrm with one.vn so I changed the cookie to the code as follows. And it was logged in.

    But when logging in, the error is as described above.

  • User Avatar
    0
    trungbttsd created

    Solved.

    I implemented the following code to remove the duplicate token.

    Thanks.