在我的应用程序web.config文件中,我存储了一个连接字符串。 我用
加密了它 '---open the web.config file
Dim config As Configuration = _
ConfigurationManager.OpenWebConfiguration( _
Request.ApplicationPath)
'---indicate the section to protect
Dim section As ConfigurationSection = _
config.Sections("connectionStrings")
'---specify the protection provider
section.SectionInformation.ProtectSection(protectionProvider)
'---Apply the protection and update
config.Save()
现在我可以使用代码
解密它 Dim config As Configuration = _
ConfigurationManager.OpenWebConfiguration( _
Request.ApplicationPath)
Dim section As ConfigurationSection = _
config.Sections("connectionStrings")
section.SectionInformation.UnProtectSection()
config.Save()
我想知道密钥存储在哪里,而且如果我的web.config文件被盗,他/她是否可以使用上面的代码解密它。
答案 0 :(得分:3)
用户密钥存储在:
[Letter]:\Documents and Settings\[User]\Application Data\Microsoft\Crypto\RSA
机器钥匙位于:
[Letter]:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys
如果有人拥有该文件和密钥然后是,则他们将能够解密。如果只有文件,没有他们将无法。
此外,如果他们在同一台服务器上使用相同的代码解密,那么是。但是,如果它们到达您的服务器,那么无论如何都是如此。
编辑以添加评论的答案:
答:如果我没弄错的话,除非你进行导入/导出,否则该密钥只能在该机器上运行。然而,正如我所说,如果有人获得了访问权限,那么你将会“死在水中”,因为受到破坏的服务器将是毁灭性的。
问:我又创建了一个Web应用程序并对其进行了加密。我发现那里没有创建新密钥。它是否为第二个应用程序使用相同的密钥?