Sko*_*šek 8 iis data-protection asp.net-core
我有一个Asp.NET Core应用程序,没有特殊的DataProtection堆栈设置 - 只是AddMvc.虽然一切都适用于IISExpress /(Kestrel),但在IIS服务器上我遇到了这个错误:
11/23/2016 18:50:14:warn: Microsoft.AspNetCore.Session.SessionMiddleware[7]
Error unprotecting the session cookie.
System.Security.Cryptography.CryptographicException: The key {6d00462a-ba7f-4f65-bb36-711605de93f2} 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)
11/23/2016 19:27:34:warn: Microsoft.Extensions.DependencyInjection.DataProtectionServices[59]
Neither user profile nor HKLM registry available. Using an ephemeral key repository. Protected data will be unavailable when application exits.
11/23/2016 19:27:34:warn: Microsoft.AspNetCore.DataProtection.Repositories.EphemeralXmlRepository[50]
Using an in-memory repository. Keys will not be persisted to storage.
11/23/2016 19:27:34:warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {27c3297d-c583-4de5-b619-489bfba62407} may be persisted to storage in unencrypted form.
11/23/2016 19:27:35:warn: Microsoft.AspNetCore.Session.SessionMiddleware[7]
Error unprotecting the session cookie.
System.Security.Cryptography.CryptographicException: The key {3cbde8ae-2dba-4c84-ada3-20ba40bdff85} 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)
Run Code Online (Sandbox Code Playgroud)
它只在登录后发生,而不是每次都发生.我试图谷歌但没有成功.
可能是第二台服务器上的某些IIS配置不同?谢谢.
此问题源于 IIS 本身的错误,该错误可能会或可能永远不会得到纠正。为了解决此问题,您需要编辑应用程序池以启用用户配置文件加载。一旦您将应用程序池设置为加载应用程序池标识的用户配置文件,应用程序将有权按预期读取和写入系统注册表。
原创文章
简而言之,确保应用程序池加载用户配置文件:
在此处下载 ps 脚本或其 .NET 模拟程序 构建它并以管理员身份运行它,如下所示:
ProvisionAutoGenKeys.exe NetCoreAppPool
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1240 次 |
| 最近记录: |