11

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

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

密钥存储在哪里?

钥匙有多长?

4

2 回答 2

10

用户级密钥存储在

\Documents and Settings{用户名}\Application Data\Microsoft\Crypto\RSA

机器级密钥

\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys

您的是用户级密钥。

于 2009-08-05T10:34:17.687 回答
1

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

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

于 2016-12-19T11:12:48.267 回答