我正在尝试加密我的web.config文件的某些部分。(密码)这对于普通的部分密钥来说很好用,就像这样:
<AppSettings>
<add key="SomePassword" value="HI I AM ENCRYPTET"/>
<AppSettings>在Global.asax中,我执行以下操作:
System.Configuration.ConfigurationManager.AppSettings["SomePassword"] = Decrypt(System.Configuration.ConfigurationManager.AppSettings["SomePassword"])
这可以很好地工作。但是当我尝试对Connection-String执行此操作时,抛出了一个异常:“该配置是只读的。”
所以,我没有权利写。有人知道如何在不编辑Connection-String类的情况下解决这个问题吗?
谢谢&问候
发布于 2015-03-20 14:44:14
您可以通过以下方式将机密移出web.config文件:
<appSettings file="..\..\AppSettingsSecrets.config"> 请参阅将密码和其他敏感数据部署到ASP.NET和Azure网站的最佳实践。http://www.asp.net/identity/overview/features-api/best-practices-for-deploying-passwords-and-other-sensitive-data-to-aspnet-and-azure
对于Azure,我喜欢使用http://www.powershellcookbook.com/recipe/PukO/securely-store-credentials-on-disk将凭据加密到磁盘。
https://stackoverflow.com/questions/19248262
复制相似问题