简体   繁体   English

WCF WSHttpBinding SOAP安全协商失败

[英]WCF WSHttpBinding SOAP Security Negotiation Failed

I've got a fairly simple WCF self-hosted service using the WSHttpBinding that just refuses to work. 我有一个相当简单的WCF自托管服务使用WSHttpBinding只是拒绝工作。 If service and client runs on the same machine there's no problem, but as soon as I move the service to the window-server 2008 the client fails the communication attempts with 如果服务和客户端在同一台机器上运行就没有问题,但是一旦我将服务移动到window-server 2008,客户端就无法通过

EXCEPTION 例外

[System.ServiceModel.Security.SecurityNegotiationException] {"SOAP security negotiation with 'http://hvw-svr-01/SIT' for target 'http://hvw-svr-01/SIT' failed. See inner exception for more details."} [System.ServiceModel.Security.SecurityNegotiationException] {“与目标'http:// hvw-svr-01 / SIT'的'http:// hvw-svr-01 / SIT'进行SOAP安全协商失败。请参阅内部异常了解更多信息细节。”}

INNER EXCEPTION 内部异常

[System.ComponentModel.Win32Exception] {"The Security Support Provider Interface (SSPI) negotiation failed. The server may not be running in an account with identity 'host/hvw-svr-01'. If the server is running in a service account (Network Service for example), specify the account's ServicePrincipalName as the identity in the EndpointAddress for the server. If the server is running in a user account, specify the account's UserPrincipalName as the identity in the EndpointAddress for the server."} [System.ComponentModel.Win32Exception] {“安全支持提供程序接口(SSPI)协商失败。服务器可能未在标识为”host / hvw-svr-01“的帐户中运行。如果服务器在服务帐户中运行(例如,网络服务),将帐户的ServicePrincipalName指定为服务器的EndpointAddress中的标识。如果服务器在用户帐户中运行,请在帐户的EndpointAddress中将帐户的UserPrincipalName指定为标识。“}

Since it's a self-hosted service I suppose I need to specify the UserPrincipalName, but no matter what I try for that property it just won't work. 由于它是一个自托管服务,我想我需要指定UserPrincipalName,但无论我尝试该属性,它都无法工作。

  • domain\\username 域\\用户名
  • domain@username 域@用户名
  • host/localhost 主机/本地主机
  • host/hvw-svr-01 主机/ HVW-SVR-01
  • ... and so on ... 等等

Tried it with different user accounts aswell, including the built-in Administrator. 尝试使用不同的用户帐户,包括内置管理员。 If I try BasicHttpBinding instead of WSHttpBinding everything works as expected. 如果我尝试BasicHttpBinding而不是WSHttpBinding,一切都按预期工作。 I read tons of articles about that problem on google (and stackoverflow) but I still cannot figure what the problem is and how to specify that identity. 我在google(和stackoverflow)上阅读了大量有关该问题的文章,但我仍然无法确定问题是什么以及如何指定该身份。

Edit: Service App.Config 编辑:服务App.Config

   <system.serviceModel>
  <services>
     <service name="SIT.Communication.Gate">
        <host>
           <baseAddresses>
              <add baseAddress="http://localhost:2323/SIT" />
           </baseAddresses>
        </host>
        <endpoint address="" binding="wsHttpBinding" contract="SIT.Core.IGate">
           <identity>
              <dns value="localhost"/>
              <userPrincipalName value="XZDom\DGrain"/>
           </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
     </service>
  </services>
  <behaviors>
     <serviceBehaviors>
        <behavior>
           <serviceMetadata httpGetEnabled="True"/>
           <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
     </serviceBehaviors>
  </behaviors>

Edit: The Client itself is basically just this code fragment 编辑:客户端本身基本上只是这个代码片段

  ChannelFactory<IGate> sitFactory = new ChannelFactory<IGate>(new WSHttpBinding(), new EndpointAddress("http://hvw-svr-01:2323/SIT")); IGate sitProxy = sitFactory.CreateChannel(); bool pong = sitProxy.Ping(); <------ throws exception 

To enable the Negotiate process to select the Kerberos protocol for network authentication, the client application must provide an SPN, a user principal name (UPN), or a NetBIOS account name as the target name. 要使协商进程能够选择Kerberos协议进行网络身份验证,客户端应用程序必须提供SPN,用户主体名称(UPN)或NetBIOS帐户名作为目标名称。 If the client application does not provide a target name, the Negotiate process cannot use the Kerberos protocol. 如果客户端应用程序未提供目标名称,则协商进程无法使用Kerberos协议。 If the Negotiate process cannot use the Kerberos protocol, the Negotiate process selects the NTLM protocol. 如果协商进程无法使用Kerberos协议,则协商进程将选择NTLM协议。

In cross-domain, kerberos has to be used. 在跨域中,必须使用kerberos。 Since service is running as local system account, a SPN identity has to be used on the client side for the target name. 由于服务作为本地系统帐户运行,因此必须在客户端使用SPN标识作为目标名称。

For more informaiton, read http://support.microsoft.com/kb/929650 有关更多信息,请阅读http://support.microsoft.com/kb/929650

Hope this helps! 希望这可以帮助!

You can opt for basic HTTP binding if WSHttpBinding is not an actual requisite. 如果WSHttpBinding不是实际必需条件,则可以选择基本HTTP绑定。 :) :)

Basic HTTP eliminates the <identiy> tag so UPN and SPN problems wouldn't occur. 基本HTTP消除了<identiy>标记,因此不会发生UPN和SPN问题。

I had the same issue and I tried almost all the settings in web.config and in the IIS server. 我遇到了同样的问题,我尝试了web.config和IIS服务器中的几乎所有设置。 And the best way for me is to set UPN when creating the client: 对我来说最好的方法是在创建客户端时设置UPN:

EndpointAddress endptAddress = 
               new EndpointAddress(
                  new Uri(your URL),
                  EndpointIdentity.CreateUpnIdentity("domain\username"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM