我已经创建了一个应用程序,它可以让机器在网络上互相交流。我想使用NetTCPBinding对消息进行加密。但是,我不需要或不需要证书或windows身份验证。我尝试将安全模式设置为Message以获得加密,并将安全性传输到none,以避免证书/windows身份验证,但仍然得到:
System.ServiceModel.Security.SecurityNegotiationException:调用者没有通过服务进行身份验证。-> System.ServiceModel.FaultException:由于身份验证失败,无法满足对安全令牌的请求。
以下是相关代码:
NetTcpBinding binding = new NetTcpBinding();
binding.Security.Mode = SecurityMode.Message;
binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;发布于 2011-08-27 12:43:14
这个问题的答案是有效的:自托管wcf服务器-从文件加载证书,而不是从证书存储加载证书
我的代码:
var certificate = new X509Certificate2("cert.pfx", "");
host = new ServiceHost(MessageProvider, address);
host.Credentials.ServiceCertificate.Certificate = certificate;
host.Credentials.ClientCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
NetTcpBinding binding = new NetTcpBinding();
binding.Security.Mode = SecurityMode.Message;
binding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate;
binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate;
host.AddServiceEndpoint(typeof(IService), binding, address);
host.Open();发布于 2011-08-25 11:44:01
我想这就是你要找的:匿名客户端的消息安全性。我认为,在您的情况下,问题在于您的服务没有在服务器端指定证书:
初始协商需要服务器身份验证,但不需要客户端身份验证。
因此,当实例化服务时,尝试执行类似于(来自MSDN)的操作:
myServiceHost.Credentials.ServiceCertificate.SetCertificate(
StoreLocation.LocalMachine,
StoreName.My,
X509FindType.FindByThumbprint,
"00000000000000000000000000000000");https://stackoverflow.com/questions/7189607
复制相似问题