.Net 加密 [英] .Net Encryption

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

问题描述

我想知道的是在配置文件中加密连接字符串的明确方法.以下是我的问题:

What I would like to know is the definite approach to encrypting connection strings in a config file. Here are my questions:

  1. 使用机器级加密,难道任何访问我服务器的人都不能编写一个小.Net程序来读取连接字符串的内容吗?

  1. Using machine-level encryption, can't anybody accessing my server write a little .Net program to read the contents of the connection strings?

如果我将我的应用程序部署到企业环境中的用户机器,并且该应用程序在配置文件中有连接字符串,我如何确保只有我的应用程序可以解密它?该场景在 ClickOnce 部署场景中特别有趣.我读过有人在第一次下载、安装和执行应用程序时将未加密的配置存储在发布服务器上并在机器级别加密.这对我来说听起来太错误了 - 连接字符串在没有保护的情况下通过电线压缩,并且在下载和应用程序执行之间的一小段时间内没有保护.

If I am deploying my application to users machines in an enterprise environment, and the application has connection strings in a config file, how can I make sure only my application can decrypt it? The scenario is especially interesting in a ClickOnce deployment scenario. I've read about people storing the config unencrypted at the publisher server and encrypting at the machine level when the app is downloaded, installed and executed for the first time. This sounds so wrong to me - connection strings zipping unprotected through the wire, and sitting unprotected for a brief amount of time between download and application execution.

我可以拥有公钥和私钥,签署我的应用程序,使用密钥加密配置文件,并且当用户执行它时,只能从已签名的应用程序解密吗?

Can I have a public and private key, sign my app, encrypt the config file with a key, and when the user executes it, decryption would only be possible from the signed application?

因为我使用 ClickOnce,所以我可以在代码中或嵌入我的加密敏感信息,因为除非版本 # 更改,否则 ClickOnce 不会检测到更改.因此,如果更改连接字符串后需要重新编译,则 app.config 的点将被静音.除了使用配置文件,我还可以采取哪些其他方法来保护服务器、客户端及其之间的连接字符串?

Since I am using ClickOnce, I could have my encrypted sensitive information in the code or embedded, because ClickOnce won't detect a change unless the version # changes. So, if I need to recompile if I change my connection string, the point of an app.config is muted. What other approaches can I take, out-side using an config file, to achieve protection of the connection strings at the server, client and in between?

推荐答案

  1. 是的.任何可以访问机器密钥的进程都可以解密用机器密钥加密的秘密.使用用户密钥加密的机密可由同一用户启动的任何进程解密.
  2. 这是不可能的.所有相反的说法都是蛇油.您的应用程序需要一个秘密来解密某些东西.没有已知的方案可以在应用程序中隐藏秘密.有各种混淆方案,但没有什么是防弹的.您能做的最好的事情就是提高标准.
  3. 没有.要么应用程序有解密某些东西的密钥,在这种情况下你回到第 2 点,或者你的应用程序有公钥,在这种情况下任何人都可以解密相同的秘密,所以你基本上对配置进行了验证(是未篡改),但配置不是秘密.
  4. 您无法在应用程序中安全地部署嵌入式机密.只是价格有多高的问题,如果您的受保护资产(秘密)值得,那么黑客就会得到它.

加密基础设施旨在保护当前用户的秘密免受其他用户的侵害.它并非旨在保护应用程序的机密不被用户使用.您要求的不是加密,而是 DRM,您需要查看 DRM 基础架构以获得答案.我不知道围绕 DRM API<的托管库/a>.

The encryption infrastructure is designed to protect the secrets of the current user from other users. It is not designed to protect the secrets of an application from the user using it. What you ask for is not encryption, is DRM, and you need to look into the DRM infrastructure for answers. I'm not aware of a managed library around the DRM API.

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

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