如何加密但不保护 WCF 消息?
我创建了一个应用程序,让机器通过网络相互通信。我想使用 NetTCPBinding 并加密消息。但是我不想要或不需要证书或 Windows 身份验证。我尝试将安全模式设置为“消息”以获取加密并将传输安全设置为“无”以避免证书/Windows 身份验证,但我仍然得到:
System.ServiceModel.Security.SecurityNegotiationException:调用者 未经过服务验证。 ---> System.ServiceModel.FaultException:安全令牌的请求 由于身份验证失败,无法满足。
这是相关代码:
NetTcpBinding binding = new NetTcpBinding();
binding.Security.Mode = SecurityMode.Message;
binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;
I've created an app that has machines talking to each other across the net. I'd like to use NetTCPBinding and encrypt the messages. However I don't want or need certificates or windows authentication. I try to set the security mode to Message to get encryption and transport security to none to avoid the certificates/windows authentication but still I get:
System.ServiceModel.Security.SecurityNegotiationException: The caller
was not authenticated by the service. --->
System.ServiceModel.FaultException: The request for security token
could not be satisfied because authentication failed.
Here's the relevant code:
NetTcpBinding binding = new NetTcpBinding();
binding.Security.Mode = SecurityMode.Message;
binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个问题的答案有效: selfhosting wcf 服务器 - 从文件而不是证书存储加载证书
我的代码:
An answer from this question works: selfhosting wcf server - load certificate from file instead of certificate store
My code:
我认为这就是您正在寻找的内容:匿名客户端的消息安全性。我想您的情况的问题是您的服务没有在服务器端指定证书:
因此在实例化服务时尝试执行类似的操作(来自 MSDN):
I think this is what you are looking for: Message Security with an Anonymous Client. I suppose the problem in your case is that your service is not specifying a certificate on server-side:
So when instantiating the service try to do something like (from MSDN):