2010-08-19 119 views
8

我使用的是我創建的一個wcf服務,當宿主機和客戶機在同一個域上時,一切正常。 當我發佈的客戶端應用程序的網絡服務器在DMZ中我收到以下錯誤:WCF安全支持提供程序接口(SSPI)協商失敗

SOAP security negotiation with 'http://10.0.0.14:3790/Bullfrog/QBService/QBService' for 
target 'http://10.0.0.14:3790/Bullfrog/QBService/QBService' failed. See inner exception 
for more details.The Security Support Provider Interface (SSPI) negotiation failed. 

這裏是我的服務主要在哪裏設置服務

 Uri baseAddress = new Uri("Http://10.0.0.14:3790/Bullfrog/QBService"); 
     ServiceHost selfHost = new ServiceHost(typeof(QBService), baseAddress); 

      try 
      { 
       selfHost.AddServiceEndpoint(
        typeof(IQBService), 
        new WSHttpBinding(), 
        "QBService"); 

       ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); 
       smb.HttpGetEnabled = true; 
       selfHost.Description.Behaviors.Add(smb); 
       selfHost.Open(); 

       Console.WriteLine("The service is ready"); 


      } 
      catch (CommunicationException ce) 
      { 
       //log.Error(ce.Message, ce); 
       Console.WriteLine(ce.Message, ce); 
       selfHost.Abort(); 
      } 

這裏是配置我的客戶端部分

<system.serviceModel> 
<bindings> 
    <wsHttpBinding> 
    <binding name="WSHttpBinding_IQBService" closeTimeout="00:01:00" 
     openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
     bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
     maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
     messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" 
     allowCookies="false"> 
     <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
      maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
     <reliableSession ordered="true" inactivityTimeout="00:10:00" 
      enabled="false" /> 
     <security mode="Message"> 
     <transport clientCredentialType="Windows" proxyCredentialType="None" 
      realm="" /> 
     <message clientCredentialType="Windows" negotiateServiceCredential="true" 
      algorithmSuite="Default" /> 
     </security> 
    </binding> 
    </wsHttpBinding> 
</bindings> 
<client> 
    <endpoint address="http://10.0.0.14:3790/Bullfrog/QBService/QBService" 
     binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IQBService" 
     contract="IQBService" name="WSHttpBinding_IQBService"> 
    <identity> 
     <userPrincipalName value="[email protected]bullfrogspas.local" /> 
    </identity> 
    </endpoint> 
</client> 

我相信問題是因爲它使用Windows身份驗證。有任何想法嗎? 謝謝!

+0

我不是100%確定的,所以我不會發布這個答案,但只有當客戶端和服務器都在同一個域或受信任的域中時,IMO Windows身份驗證纔是可能的。順便說一句。如果內部網絡和DMZ都是你的企業基礎設施的一部分,你爲什麼選擇WsHttpBinding和消息安全?這是最慢的選擇。 – 2010-08-19 20:56:38

+0

如果內部網絡和DMZ都是你的企業基礎設施的一部分你爲什麼選擇WsHttpBinding和消息安全? - 因爲我不知道其他方式:)我應該使用哪一個?如上所述,我相信它是造成問題的Windows身份驗證。那麼我需要使用什麼呢? 謝謝! – twal 2010-08-19 21:02:06

回答

7

我不認爲這會起作用,我沒有環境來快速測試它。 SSPI使用NTLM或Kerberos(如果未使用服務憑證協商,則爲必需)以在服務上對客戶端和客戶端上的服務進行身份驗證。 NTLM和Kerberos都期望相同的域或受信任的域。

如果要使用消息安全性,可以更改配置以使用證書或用戶名+密碼(服務仍需要證書)。您可以在活動目錄或任何其他憑證存儲中驗證用戶名和密碼。

請記住,郵件安全性是最慢的。使用傳輸安全性(HTTPS)可以實現更好的性能 - 網絡設備可以加速其性能。如果您使用HTTPS,則可以將其與基本身份驗證結合使用,並從代碼中提供客戶端憑據,以便在內部區域中調用服務,並使用域憑據進行身份驗證。服務將通過用於HTTPS的證書進行身份驗證。 HTTPS還允許在客戶端向服務發送證書的情況下進行身份驗證 - 如果配置正確的客戶端證書可以映射到域帳戶。這兩種方法與消息安全中提到的方法類似,但不是在SOAP頭中發送憑證,而是使用HTTP頭。

+0

謝謝!我很感激你的幫助。我使用基本綁定工作。儘管我可能需要在使用它之前增加安全性。我不知道,當主機位於防火牆之後,唯一的客戶端在DMZ中時,安全的風險和需求是什麼? – twal 2010-08-23 14:40:36

+0

這取決於你的網絡架構。如果您可以直接訪問服務(無需任何代理),則可以使用HTTPS而不會出現任何問題。如果您通過某些應用程序代理(如ISA服務器)訪問服務,則您將在客戶端和ISA之間以及ISA和服務之間的另一個HTTPS連接之間分開。消息將在ISA服務器上不安全,但通常不會造成問題,因爲ISA服務器在您的控制之下。 – 2010-08-23 22:17:36

1

我想你應該註釋下面的代碼在你的web.config

<identity> 
     <userPrincipalName value="[email protected]" /> 
</identity> 

,因爲它解決了我的問題。

相關問題