生成新的machinekey会中断现有用户的登录

时间:2017-06-20 08:42:11

标签: asp.net authentication cookies

我们有一个应用程序,我们想要更改机器密钥。此密钥用于加密ASP.NET中的会话,cookie(以及其他)。

更改计算机密钥时,我们希望ASP.NET使所有现有Cookie无效,并在尝试访问受身份验证保护的页面时显示登录页面。但是,我们最终会遇到以下异常:

[CryptographicException: Error occurred during a cryptographic operation.] System.Web.Security.Cryptography.HomogenizingCryptoServiceWrapper.HomogenizeErrors(Func`2 func, Byte[] input) +178 System.IdentityModel.Tokens.SessionSecurityTokenHandler.ApplyTransforms(Byte[] cookie, Boolean outbound) +179 System.IdentityModel.Tokens.SessionSecurityTokenHandler.ReadToken(XmlReader reader, SecurityTokenResolver tokenResolver) +827 System.IdentityModel.Tokens.SessionSecurityTokenHandler.ReadToken(Byte[] token, SecurityTokenResolver tokenResolver) +87 System.IdentityModel.Services.SessionAuthenticationModule.ReadSessionTokenFromCookie(Byte[] sessionCookie) +569 System.IdentityModel.Services.SessionAuthenticationModule.TryReadSessionTokenFromCookie(SessionSecurityToken& sessionToken) +306 System.IdentityModel.Services.SessionAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs eventArgs) +159 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +229 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +98

(我为这里糟糕的格式道歉。)

这意味着通过更改机器密钥来破坏现有登录用户,这不是我们想要的。我们还可以清除现在之前的cookie,但这听起来相当骇人听闻。

有没有办法解决这个问题而没有明确地使用户的cookie失效,例如this postthis post中的目的?

0 个答案:

没有答案
相关问题