gpt4 book ai didi

authentication - "Error unprotecting the session cookie"异常

转载 作者:行者123 更新时间:2023-12-03 15:52:25 24 4
gpt4 key购买 nike

我有一个带有此身份验证设置的 Asp.NET MVC 应用程序:

配置服务():

services.AddSession()
services.AddAuthentication(sharedOptions => sharedOptions.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme);

配置():
        app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
{
ClientId = "xx",
Authority = "xx",
Events = new OpenIdConnectEvents { OnRemoteFailure = this.OnAuthenticationFailed }
});

当托管在 IIS 中时,一些用户会收到以下异常:
Microsoft.AspNetCore.Session.SessionMiddleware, 
Error unprotecting the session cookie.
System.Security.Cryptography.CryptographicException: The key {9ec59def-874e-45df-9bac-d629f5716a04} 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.Session.CookieProtection.Unprotect(IDataProtector protector, String protectedText, ILogger logger)

我已经在托管服务器上运行了 https://github.com/aspnet/DataProtection/blob/dev/Provision-AutoGenKeys.ps1

网络只有 HTTPS 绑定(bind),SSL 证书是好的并已签名。什么可能导致这个问题?那个“关键”值实际上是什么?

最佳答案

services.AddSession(options => {
options.IdleTimeout = TimeSpan.FromHours(12);
options.Cookie.Name = ".yourApp.Session"; // <--- Add line
options.Cookie.IsEssential = true;
});

关于authentication - "Error unprotecting the session cookie"异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40865011/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com