ASP.NET Core DPAPI PersistKeyToFileSystem加密密钥

问题描述

我正在使用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>

我也希望磁盘持久密钥也要加密。我该如何实现?

doc显示了带有加密密钥的示例。 用加密密钥生成xml密钥文件需要什么api方法调用

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)