C#connectionString加密问题 [英] C# connectionString encryption questions

查看:228
本文介绍了C#connectionString加密问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习如何加密我们的C#(3.5)应用程序的ConnectionString。我阅读了.Net Framwork开发者指南( http:// msdn.microsoft.com/en-us/library/89211k9b(VS.80).aspx )关于安全连接字符串。但不完全明白内容。


  1. 它说连接字符串只能在计算机上加密。我们有一个发行机,将构建我们的应用程序,它将生成OurApp.exe.config,然后将其安装到许多产品机器上。我们是否需要将此加密过程与我们的应用程序分开并在单独的产品机器上运行?


  2. 我们可能会使用code > RSAProtectedConfigurationProvider 。它提到我们需要这个提供者的加密密钥。何时以及如何提供加密密钥?


谢谢,

解决方案

你只需要运行加密过程一次。但是,生成机器密钥后,需要在目标机器的所有machine.config文件中传播。 machine.config应该位于这里:

%FRAMEWORKDIR%\%FRAMEWORKVERSION%\CONFIG 

如何:在ASP.NET 2.0中配置MachineKey
:此链接有一个配置密钥的部分< machineKey validationKey =[生成的值在这里]

decryptKey =AutoGenerate,IsolateApps
validation =SHA1decrypt =Auto/>
以及如何在机器之间共享。


I am learning how to encrypt the ConnectionString for our C# (3.5) Application. I read the .Net Framwork Developer Guide (http://msdn.microsoft.com/en-us/library/89211k9b(VS.80).aspx) about securing connection string. but not fully understand the contents.

  1. It says "The connection string can only be decrypted on the computer on which it was encrypted." We have a release machine which will build our application which will generate the OurApp.exe.config and then install it to many product machines. Is that meam we have to have this encryption process separated with our application and run it at individual product machine?

  2. We may use the "RSAProtectedConfigurationProvider". It mentioned we need encryption key for that provider. when and how we should provide the encryption key?

thanks,

解决方案

You only have to run the encryption process once. However, after generating the machine key, you need to propagate that in all the machine.config files in the target machines. The machine.config should be located here:

%FRAMEWORKDIR%\%FRAMEWORKVERSION%\CONFIG

How To: Configure MachineKey in ASP.NET 2.0 : This link has a section on configuring the config key <machineKey validationKey="[generated value here]"
decryptionKey="AutoGenerate,IsolateApps" validation="SHA1" decryption="Auto" />
and how to share this between machines.

这篇关于C#connectionString加密问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆