Using an in-memory repository. Keys will not be persisted to storage.问题

记录一个问题:

2020-04-13 15:26:18.3489|Microsoft.AspNetCore.DataProtection.Repositories.EphemeralXmlRepository|WARN|Using an in-memory repository. Keys will not be persisted to storage.

2020-04-13 15:26:18.3577|Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager|WARN|Neither user profile nor HKLM registry available. Using an ephemeral key repository. Protected data will be unavailable when application exits.

2020-04-13 15:26:18.3577|Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager|WARN|No XML encryptor configured. Key {ae3c6013-0afe-4b65-a66a-f1b52b652685} may be persisted to storage in unencrypted form.

问题信息:
Using an in-memory repository. Keys will not be persisted to storage.
Neither user profile nor HKLM registry available. Using an ephemeral key repository. Protected data will be unavailable when application exits.
No XML encryptor configured. Key {ae3c6013-0afe-4b65-a66a-f1b52b652685} may be persisted to storage in unencrypted form

出现时间(同事说的):
每次涉及到xml格式传输的接口就会报这个,iis配置没问题的样子。

在网上查到在 ASP.NET Core 中如果在 DataProtection 中使用了 PersistKeysToFileSystem 或 PersistKeysToFileSystem就会有这个警告。

原因:

看了很多文章,不管如何表达好像都和加密/数据保护/iis对netcore没变化等等,相关的。

 

iis的配置问题解决方案:

此问题源于IIS 本身中的错误,该错误可能得到纠正,也可能永远不会得到纠正。为了解决此问题,您需要编辑应用池以启用用户配置文件加载。将 App Pool 设置为加载应用程序池标识的用户配置文件后,应用程序将具有按预期读取和写入系统注册表的权限。

Using an in-memory repository. Keys will not be persisted to storage.问题

有帮助的文章:
https://www.puresourcecode.com/dotnet/net-core/using-an-in-memory-repository-keys-will-not-be-persisted-to-storage-asp-net-core-under-iis/
http://www.voidcn.com/article/p-wsixnuvn-buw.html
https://cypressnorth.com/programming/solved-using-memory-repository-keys-will-not-persisted-storage-asp-net-core-iis/