C# 带有rsaptectedconfigurationprovider的ProtectSection键在哪里?
我正在使用System.Configuration对自定义配置部分中的一些密码进行加密和保护C# 带有rsaptectedconfigurationprovider的ProtectSection键在哪里?,c#,configuration,encryption,rsa,C#,Configuration,Encryption,Rsa,我正在使用System.Configuration对自定义配置部分中的一些密码进行加密和保护 static public void SetPassAndProtectSection(string newPassword) { // Get the current configuration file. System.Configuration.Configuration config = ConfigurationManager.OpenExeConfigura
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);
}
这似乎很好,但我需要一些额外的信息为我的文档
钥匙存放在哪里
密钥有多长?用户级密钥存储在 \文件及 设置{UserName}\Application 数据\Microsoft\Crypto\RSA 机器级钥匙位于 \文档和设置\All 用户\应用程序 数据\Microsoft\Crypto\RSA\MachineKeys
您的是用户级密钥。我有一个场景,需要授予本地服务帐户访问Windows 2012服务器上的RsaProtectedConfigurationProvider密钥的权限
最后,在C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys上授予访问权限就成功了。谢谢h0b0我检查了它,这是正确的。我有点吃惊地发现机器级密钥位置的默认访问权限为“everyone..read”。我认为我需要使用用户级密钥,因为在我的情况下,密钥的用户是作为特定帐户运行的windows服务。感谢您的回复。注意:在更高版本的windows上,位置可能已更改。我回答的那一个不一样。