我正在使用 AWS Elastic Beanstalk 部署一个网站,并且可以非常轻松地将其部署到负载平衡的网络场中。
现在,我想对我已部署的网站的 web.config 中的某些部分进行加密,无论是在部署之前还是部署之后。
有很多文章介绍如何使用 Aspnet_regiis.exe 工具使用 RSA 来加密某个部分,但是,问题是当您处理网络场时,因为您需要将私钥导出到其他服务器。
摘自这篇文章http://msdn.microsoft.com/en-us/library/ff647398.aspx请参阅:
Web Farm Scenarios If you want to deploy the same encrypted configuration file on multiple servers in a Web farm, you should use the RSAProtectedConfigurationProvider. This provider makes it easy for you encrypt the data on one server computer and then export the RSA private key needed to decrypt the data. You can then deploy the configuration file and the exported key to the target servers, and then re-import the keys.
但是,我的问题是,在负载均衡的环境中,服务器会由于自动缩放规则而上下波动,我需要一个流程来自动化 key 的管理,即在新部署的服务器上导入用于加密 Web.config 的私钥。
有人做过这件事或者可以提供一些见解吗?
最佳答案
按照 @kukido 的建议,您需要做的是创建一个包含以下内容的 .ebextension 文件。
commands:
encryptConfig:
command: aspnet_regiis.exe -pe "connectionStrings" -app /
cwd: %windir%\\Microsoft.NET\\Framework64\\v4.0.30319
关于asp.net - 如何使用 Amazon Elastic Beanstalk 加密 web.config 部分并部署到多个服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18369268/