在 WCF 中验证调用者/服务器

发布于 2024-10-15 03:07:54 字数 445 浏览 3 评论 0原文

我的场景:

  • 许多位于我控制
  • 范围之外的环境中的 WCF 客户端服务器要么是我的,要么位于我控制范围之外的环境中

,所以最坏的情况是客户端和服务器超出了我的控制范围。更具体地说,我可能假设托管此代码的人可能会尝试恶意冒充服务器或客户端(服务器更有可能)。但是,客户端需要验证服务器是我的代码,服务器需要验证客户端是我的代码。我已经看过所有使用证书的建议;但是,考虑到我的情况,这是一个选择吗?

我考虑过的一种方法是编写 IClientMessageInspector 和 IDispatchMessageInspector 来设置和验证双方的自定义 SOAP 标头。我将根据源代码中包含的密钥创建 HMAC 签名(假设我有办法隐藏它),然后根据消息正文验证摘要。

我觉得这会起作用;然而,我觉得这里可能缺少一些更开箱即用的东西。我是否已经接近、偏离轨道了?感谢您的指导!

My scenario:

  • Many WCF clients which are in environments outside of my control
  • Server will either be mine OR in an environment outside of my control

So worst case the client and the server is outside of my control. More specifically, I might assume that someone hosting this code could try to maliciously impersonate either the server or the client (the server being more likely). However, the client needs to verify that the server is my code and the server needs to verify that the client is my code. I've seen all the recommendations to use certificates; however, is that an option given my scenario?

One approach I've considered is to write an IClientMessageInspector and an IDispatchMessageInspector to set and verify a custom SOAP header on both sides. I would create an HMAC signature based on a secret key contained within the source code (assume I have a way to keep this hidden) and then verify the digest based on the message body.

I feel like this would work; however, I feel like there might be something more out-of-the-box that I'm missing here. Am I close, way off track? Thanks for any guidance!

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

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

发布评论

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

评论(2

此岸叶落 2024-10-22 03:07:54

证书绝对适合您的情况。

您的服务器将很容易被客户端验证,因为它将提供每个客户端都知道的证书,SSL 是一个不错的选择。

服务器还可以通过请求每个客户端提供证书来对客户端进行身份验证(服务器可以检查证书的特定颁发者 - 在这种情况下是您自己的颁发者)。

现在您只需要正确管理/保护您的证书服务器以确保它不会受到损害。

Certificates are definitely the way to go in your situation.

Your server will easily be authenticated by clients because it will provide a certificate known to each client, SSL is a good option here.

The server will also be able to authenticate clients by requesting that every client should provide a certificate (server can check for a specific issuer of the certificate - your own issuer in that case).

Now you just need to correctly manage/secure your certificate server to make sure that it won't be compromised.

や莫失莫忘 2024-10-22 03:07:54

我认为没有任何开箱即用的方法可以做到这一点,只是因为服务器验证调用服务的客户端上的代码是否是授权代码是一个不寻常的要求。

一般来说,按如下方式建立信任就足够了:

  1. 服务器有证书并且服务使用 SSL - 这样客户端就确信他们正在连接到正确的服务器计算机。
  2. 客户端向服务器提供身份验证详细信息(例如用户名/密码、证书等),以便服务器知道连接的客户端是可信的。

您试图采取额外的步骤来验证不仅验证了用户/机器,而且验证了正在运行的代码 - 这简直是矫枉过正。如果正在运行的代码经过验证,则可能是:

  1. 其中一台机器已受到损害,在这种情况下,您需要担心更大的问题。
  2. 您的一位用户针对您的服务编写了代码并“非法”使用它。如果您的服务只允许授权用户执行“危险”操作,这应该不是问题。

I don't think there is anything out of the box to do this, simply because it is an unusual requirement for the server to verify that the code on the client calling the service is authorized code.

Generally, it is sufficient to establish trust as follows:

  1. Server has a certificate and service uses SSL - this way clients are confident that they are connecting to the correct server machine.
  2. Clients provide authentication details (eg username/password, certificate etc) to the server so the server knows the connecting client can be trusted.

You are attempting to go the extra step to verify that not only are the users/machines verified, but also that the code running is verified - this is simply overkill. If the code running is not verified, either:

  1. One of the machines has been compromised, in which case you have bigger issues to worry about.
  2. One of your users has written code against your service and is using it 'illegally'. This should not be a problem if your service only allows authorized users to perform 'dangerous' operations.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文