【问题标题】:ProtectSection with RsaProtectedConfigurationProvider where does the Key go?ProtectSection 和 RsaProtectedConfigurationProvider 密钥在哪里?
【发布时间】:2010-11-14 14:18:47
【问题描述】:

我正在使用 System.Configuration 来加密和保护自定义配置部分中的一些密码:-.

static public void SetPassAndProtectSection(string newPassword)
{

    // Get the current configuration file.
    System.Configuration.Configuration config =
        ConfigurationManager.OpenExeConfiguration(
        ConfigurationUserLevel.None);


    // Get the section.
    MyAppProtectedSection section = 
        (MyAppProtectedSection)config.GetSection(DEFAULT_SECTION_NAME);

    section.DBPassword = newPassword;

    // Protect (encrypt)the section.
    section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");

    // Save the encrypted section.
    section.SectionInformation.ForceSave = true;

    config.Save(ConfigurationSaveMode.Full);
}

这似乎工作正常,但我的文档需要一些额外信息。

密钥存储在哪里?

钥匙有多长?

【问题讨论】:

    标签: c# configuration encryption rsa


    【解决方案1】:

    用户级密钥存储在

    \文档和 设置{用户名}\应用程序 数据\微软\加密\RSA

    处的机器级键

    \文档和设置\所有 用户\应用程序 数据\Microsoft\Crypto\RSA\MachineKeys

    您的是用户级密钥。

    【讨论】:

    • 谢谢 h0b0 我检查了它,这是正确的。我有点震惊地发现机器级密钥位置的默认访问权限为“everyone..read”。我在想我将需要使用用户级别的密钥,因为在我的情况下,密钥的用户是作为特定帐户运行的 Windows 服务。感谢您的回复。
    • 注意:位置可能在更高版本的 Windows 上发生了变化。我的答案不同。
    【解决方案2】:

    我有一个场景,我需要授予本地服务帐户访问 Windows 2012 服务器上的 RsaProtectedConfigurationProvider 密钥的权限。

    最后,授予对 C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys 的访问权限就成功了。

    【讨论】:

      猜你喜欢
      • 2010-12-01
      • 2020-06-30
      • 1970-01-01
      • 2011-09-28
      • 1970-01-01
      • 2011-04-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多