我们有一个WPF应用程序使用netTcpBinding
使用TransportWithMessageCredential
安全性连接到WCF服务,clientCredentialType
设置为Windows
以获得消息和传输安全性。 IIS应用程序池在域用户的身份下运行。
以上设置在本地工作正常(意味着WCF服务和WPF应用程序在同一个盒子上运行)。当WPF应用程序位于不同的框中时,通信将失败并显示以下错误:
System.ServiceModel.Security.SecurityNegotiationException:SOAP 安全谈判 'net.tcp://serv01.domain.local:30128 / UsersService.svc'用于目标 'net.tcp://serv01.domain.local:30128 / UsersService.svc'失败。看到 更多细节的内部异常。 ---> System.ComponentModel.Win32Exception:安全支持提供程序 接口(SSPI)身份验证失败。服务器可能没有运行 在身份'host / serv01.domain.local'的帐户中。如果 服务器正在服务帐户中运行(例如网络服务), 将帐户的ServicePrincipalName指定为中的标识 服务器的EndpointAddress。如果服务器在用户中运行 帐户,将帐户的UserPrincipalName指定为身份 服务器的EndpointAddress。在 System.ServiceModel.Security.WindowsSspiNegotiation.GetOutgoingBlob(字节[] incomingBlob,ChannelBinding channelbinding,ExtendedProtectionPolicy protectionPolicy)at System.ServiceModel.Security.SspiNegotiationTokenProvider.GetNextOutgoingMessageBody(消息 incomingMessage,SspiNegotiationTokenProviderState sspiState)at System.ServiceModel.Security.IssuanceTokenProviderBase
1.GetNextOutgoingMessage(Message incomingMessage, T negotiationState) at System.ServiceModel.Security.IssuanceTokenProviderBase
1.DoNegotiation(时间跨度 超时)---内部异常堆栈跟踪结束---
盒子之间没有防火墙。此外,当Web服务器上的IIS使用LocalService身份时,应用程序之间的通信工作正常。
可能导致问题的原因是什么?如何确定根本原因?我没有在事件日志中看到任何其他错误消息,这些消息可能会有所帮助。
答案 0 :(得分:0)
很难找到答案,但在我的情况下,我需要在主机的ServicePrincipalName中注册我的IIS身份服务帐户。答案可在此页面上找到:http://www.getshifting.com/wiki/setupn
您需要做的是:
1)运行命令setspn -l domain\identity_user
其中" domain\identity_user
"是运行IIS的用户帐户。如果一切设置正确,则此命令必须从错误消息中返回SPN。在我的情况下 - 修复后 - 它返回:
HOST/SERV01
HOST/SERV01.DOMAIN.LOCAL
2)如果列表为空,则需要添加这些SPN。运行:
setspn -A HOST/SERV01 domain\identity_user
setspn -A HOST/SERV01.DOMAIN.LOCAL domain\identity_user
就是这样。