我正在使用ASP.NET Core DPAPI。当前使用的密钥是未保护的。 文档中显示了一个示例,显示了加密的密钥,但我无法弄清楚用于此的api设置是什么。
我正在使用以下内容:
services
.AddDataProtection()
.SetApplicationName("MyApp")
.SetDefaultKeyLifetime(TimeSpan.FromDays(3))
.PersistKeysToFileSystem(new DirectoryInfo("C:\MyDir"));
以下是生成的 XML 文件的节选内容:
<descriptor>
<encryption algorithm="AES_256_CBC" />
<validation algorithm="HMACSHA256" />
<masterKey p4:requiresEncryption="true" xmlns:p4="http://schemas.asp.net/2015/03/dataProtection">
<!-- Warning: the key below is in an unencrypted form. -->
<value>123345689...0987654321</value>
</masterKey>
</descriptor>
</descriptor>
我希望磁盘持久化密钥也能被加密。我该如何实现这一点? 这个文档展示了一个使用加密密钥的示例。 需要哪些API方法调用才能生成具有加密密钥的xml密钥文件?