加密App.config中的配置组System.ServiceModel

发布于 2024-09-07 03:44:03 字数 411 浏览 1 评论 0原文

我们正在部署一个客户端应用程序,需要加密 system.serviceModel 配置组。我一直在 StackOverflow 上搜索执行此操作的最佳方法,大多数响应都是“将 app.config 重命名为 web.config,使用 ASP.NET 实用程序加密,然后部署”或“覆盖”保护这些部分的安装方法”。

我们使用 ClickOnce,因此应用程序是按每个用户安装的,因此我们可能会为每个用户使用 DPAPI。

我知道如何通过“保护/取消保护”部分加密/解密部分,但我无法找出调用这些部分的最佳位置。

一些黑暗中的镜头:

在安装时调用保护,在应用程序启动时取消保护,以及在应用程序关闭时保护。

安装时调用保护,取消保护会自动完成。这让我很困惑,因为我找不到 DPAPI 发挥其魔力的基本方式,而且我不相信我不理解的东西。

We are deploying a client app and need to encrypt the system.serviceModel configuration group. I have been searching on StackOverflow for the better part of the day for the best way to do this and most responses have either been "rename app.config to web.config, encrypt with the ASP.NET utilty, and deploy" or "override the install method to protect the sections".

We are using ClickOnce so app is installed on a per user basis so we'll probably use DPAPI per user.

I know how to encrypt/unencrypt sections via Protect/Unprotect section but I can't figure out the best place to call these.

Some shots in the dark:

Call protect on install, unprotect on app launch, and protect on app close.

Call protect on install, unprotect is automagically done. This confuses me as I cannot find the underlying ways that DPAPI does its magic and I don't trust something I don't understand.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黯然 2024-09-14 03:44:03

为什么您需要在应用程序启动时专门“取消保护”? .NET 将透明地为您解密这些条目。

所以基本上:

  • 在文件将驻留在的机器上安装时进行加密,
  • 然后像往常一样使用它!

无需继续解密 .NET 配置部分 - .NET 将根据需要执行此操作。这样,您就可以将 MyApp.exe.config 完全或部分加密地保存在磁盘上,而仅在内存中,您才会有一些已解密的条目。

查看 Jon Galloway 的 关于该主题的博客文章

Why do you need to specifically "unprotect" on app launch? .NET will transparently decrypt those entries for you.

So basically:

  • encrypt on install on that machine that the file is going to reside on
  • use it just like always!

There's no need to keep decrypting the .NET configuration sections - .NET will do this as needed. This way, you can leave your MyApp.exe.config fully or partially encrypted, on disk, and only in memory, you'll have some entries that are decrypted.

Check out Jon Galloway's blog post on the topic.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文