简体   繁体   English

安全的Windows服务配置文件

[英]Secure windows service config file

I have a windows service with an accompanying config file. 我有一个Windows服务以及随附的配置文件。 The service is going to be installed on a bunch of lab computers and monitor things such as diskspace, network connectivity, logins, etc. 该服务将被安装在一堆实验室计算机上,并监视诸如磁盘空间,网络连接,登录等内容。

After a set interval, it will report the statistics to a Database. 设置间隔后,它将把统计信息报告给数据库。 In order to connect to the DB, I currently have the application user's name and password stored in the connection string, which can be found in the config file. 为了连接到数据库,我目前在连接字符串中存储了应用程序用户的名称和密码,可以在配置文件中找到它们。

What's the best way to secure this, such that regular users cannot access it? 确保这一点的最佳方法是什么,以使普通用户无法访问它? We do a similar thing here with our webapps using the Web.config, and we have IIS setup such that people can't browse into the directory and read it. 我们在这里使用Web.config在我们的Web应用程序中执行类似的操作,并且我们具有IIS设置,使人们无法浏览目录并读取目录。

Is there a best practice to securing a config file stored locally on each machine for a windows service? 是否有最佳实践来保护Windows服务在每台计算机上本地存储的配置文件的安全?

Use the same method that you would use for web.config 使用与web.config相同的方法

1- Go to the windows service folder, where configuration file is located 1-转到配置文件所在的Windows服务文件夹

2- Rename the config file to web.config (back it up first) 2-将配置文件重命名为web.config(首先备份它)

3- Execute: 3-执行:

c:\Windows\Microsoft.NET\Framework64\[the asp versino]\aspnet_regiis.exe -pef "[name of the config file to encrypt]" .

4- Rename the web.config back to the original name 4-将web.config重命名回原始名称

More info here https://msdn.microsoft.com/en-us/library/zhhddkxy.aspx 更多信息在这里https://msdn.microsoft.com/zh-cn/library/zhhddkxy.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM