我正在尝试访问wcf客户端。我知道人们现在正在获取信息,所以我知道它有效。我的问题是我似乎无法超越它。该服务是一种相互认证的服务。我在我的本地机器上的个人商店中有相应的证书。即使这样,我得到以下例外:
A call to SSPI failed, see inner exception
深入搜索异常,我看到了:
Message : The target principal name is incorrect
我该如何解决这个问题?我是否需要冒充应用程序池运行的用户?我是否需要添加Identity \ ServicePrincipleName或Identity \ UserPrincipleName?有没有人遇到类似的问题?
在这里查看我对类似问题的回答:netTCP binding Soap Security Negotiation Failed。本指南应适用于其他绑定,而不仅仅是TCP。
我重新生成了客户端,output.config文件中的端点现在在端点标记中有<identity>
<userPrincipalName value="[email protected]" />
</identity>
。所以新的端点看起来像 -
<endpoint address="net.tcp://machinename:6001/ReferenceDataService" binding="netTcpBinding" bindingConfiguration="netTcpBindingConf" contract="IReferenceDataService" >
<identity>
<userPrincipalName value="[email protected]" />
这解决了我的问题
对我来说,当我在端点中指定服务器的用户名时,它就起作用了。不是客户的用户名。它是UPN,而不是SPN。
new EndpointAddress(
new Uri("net.tcp://server:1234/MyWcf/svc"),
EndpointIdentity.CreateUpnIdentity("[email protected]"))
根据我的理解,客户端会验证它是否与预期用户交谈。