【发布时间】:2011-02-16 10:09:51
【问题描述】:
我在这里遇到了一个奇怪的情况。我得到它的工作,但我不明白为什么。 情况如下:
我的应用程序(网站)必须调用 WCF 服务。 WCF 服务公开 netTcpBinding 并需要传输安全性 (Windows)。
客户端和服务器在同一个域中,但在不同的服务器上。
因此生成客户端会导致以下配置(大部分是默认配置)
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="MyTcpEndpoint" ...>
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:xxxxx/xxxx/xxx/1.0"
binding="netTcpBinding" bindingConfiguration="MyTcpEndpoint"
contract="Service.IMyService" name="TcpEndpoint"/>
</client>
</system.serviceModel>
当我运行网站并调用服务时,我收到以下错误:
System.ServiceModel.Security.SecurityNegotiationException: Either the target name is incorrect or the server has rejected the client credentials. ---> System.Security.Authentication.InvalidCredentialException: Either the target name is incorrect or the server has rejected the client credentials. ---> System.ComponentModel.Win32Exception: The logon attempt failed
--- End of inner exception stack trace ---
at System.Net.Security.NegoState.EndProcessAuthentication(IAsyncResult result)
at System.Net.Security.NegotiateStream.EndAuthenticateAsClient(IAsyncResult asyncResult)
at System.ServiceModel.Channels.WindowsStreamSecurityUpgradeProvider.WindowsStreamSecurityUpgradeInitiator.InitiateUpgradeAsyncResult.OnCompleteAuthenticateAsClient(IAsyncResult result)
at System.ServiceModel.Channels.StreamSecurityUpgradeInitiatorAsyncResult.CompleteAuthenticateAsClient(IAsyncResult result)
--- End of inner exception stack trace ---
Server stack trace:
at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
....
现在,如果我像这样更改客户端的配置:
<endpoint address="net.tcp://localhost:xxxxx/xxxx/xxx/1.0"
binding="netTcpBinding" bindingConfiguration="MyTcpEndpoint"
contract="Service.IMyService" name="TcpEndpoint">
<identity>
<dns />
</identity>
</endpoint>
一切正常,我的服务器很高兴地报告说它被托管我网站的 AppPool 的服务帐户调用。都很好。
我现在的问题是:为什么会这样?这是做什么的?我只是通过反复试验得到了这个解决方案。在我看来,<dns /> 标签的所有作用似乎就是告诉客户端使用默认 DNS 进行身份验证,但它不这样做吗?
更新
所以经过更多的研究和反复试验,我仍然没有找到这个问题的答案。
在某些情况下,如果我不提供<dns />,我会收到Credentials rejected 错误,但如果我提供<dns value="whatever"/>config,它会起作用。为什么?
【问题讨论】:
-
我们的客户端/服务 WCF 通信存在此类 SSPI 问题已经有一段时间了,但始终无法正确解决,并且仅在某些计算机上的某些用户中发生。 “DNS”身份——即使是一个空的身份——似乎也能打勾……哇。
标签: wcf configuration dns wcf-security wcf-client