【问题标题】:Issue in message security in WCF using certificate authentication使用证书身份验证的 WCF 中的消息安全问题
【发布时间】:2012-05-24 05:40:45
【问题描述】:

我有 WCF 服务,我使用证书实现了消息安全性。但是当我尝试从我的客户端应用程序连接 WCF 服务时,我收到以下错误:

调用者未经服务验证。

我的配置设置如下:

服务设置:

ServiceHost host = new ServiceHost(typeof(HostService));
NetTcpBinding tcpBinding = new NetTcpBinding(SecurityMode.Message);
tcpBinding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate;
host.AddServiceEndpoint(typeof(IHostService), tcpBinding, "net.tcp://192.168.39.28:8000/HostService");
host.Credentials.ServiceCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.My, X509FindType.FindBySubjectName, "server_cert");

客户端设置:

NetTcpBinding tcpBinding = new NetTcpBinding(SecurityMode.Message);
tcpBinding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate;
DuplexChannelFactory<IHostService> serviceFactory = new DuplexChannelFactory<IHostService>(new InstanceContext(MainWindow), tcpBinding, "net.tcp://192.168.39.28:8000/HostService");
serviceFactory.Credentials.ClientCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.My, X509FindType.FindBySubjectName, "client_cert");
serviceFactory.CreateChannel();

我使用 makecert 命令创建了 server_cert 和 client_cert 证书。你能指导我我错过了什么吗?

【问题讨论】:

    标签: wcf security


    【解决方案1】:

    调试证书相关问题很痛苦,我强烈推荐使用wireshark。在您的情况下,您的客户端可能甚至没有发送证书。如果客户端证书由另一个证书签名,请确保将其(它们)放入客户端和服务器上的受信任根目录中。

    【讨论】:

    • 如何将证书放在客户端和服务器上的受信任根目录中。受信任的根是什么意思?它是任何文件夹位置吗?有什么特殊的方法需要将证书放在受信任的根目录中,还是我们可以手动复制证书?
    • @SeaChange:我在以下链接中找到了解决此问题的方法:msdn.microsoft.com/en-us/library/ff647171.aspx 它解释了在商店中创建和安装证书的所有步骤。
    猜你喜欢
    • 2010-12-06
    • 2014-07-28
    • 1970-01-01
    • 2011-06-08
    • 2012-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-21
    相关资源
    最近更新 更多