我正在创建一个WCF应用程序,其中将使用证书来加密客户端和服务器之间的通信。在我的开发环境中,我想使用通过makecert创建的测试证书/自签名证书。 (仅服务器具有证书,客户端则没有)。
我已将证书安装到证书存储中,并且一切正常。在客户端上,由于我正在使用测试证书,所以certificateValidationMode当前设置为“false”。
我的问题:
在客户端上的app.config中,我需要这样指定identity元素:
<endpoint ... >
<identity>
<dns value="<Name-Of-Server-Computer>"/>
</identity>
</endpoint>
如果删除标识元素,则在尝试连接到服务器时会在客户端中收到以下错误消息:
Identity check failed for outgoing message. The expected DNS identity of the remote endpoint was 'localhost' but the remote endpoint provided DNS claim 'Name-Of-Server-Computer'. If this is a legitimate remote endpoint, you can fix the problem by explicitly specifying DNS identity 'Name-Of-Server-Computer' as the Identity property of EndpointAddress when creating channel proxy.
所以这是我的问题:
最佳答案
检查始终进行-应该这样做。基本上,WCF将检查证书是否颁发给您的服务所在的域名(yourcompany.com)或计算机名称。这是我永远不会禁用的安全检查!否则,任何欺骗您服务的人都可以使用针对任意域/机器名称发出的任何证书,并获得您的访问量-而不是您想要的!
因此,您需要确定的是,您在生产服务器上的真实证书确实已颁发给该生产服务器将属于的域名,例如,如果您的生产服务器将位于“production.yourcompany.com”中,则需要将该证书签发到该域。
马克
关于wcf - WCF为什么提示身份检查失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1629715/