2011-04-27 181 views
2


我創建了一個wcf服務,並且可以成功地在客戶端應用程序中引用它。但是,當我實施X509證書時出現問題。WCF代理錯誤使用X509證書

1)當我更改服務使用x509證書時,我無法創建代理,因爲mex端點未在瀏覽器中顯示。因此,在這種情況下,我應該如何在客戶端應用程序中引用服務,何時保證服務以及mex端點未被暴露?

2)我可以同時使用消息和傳輸安全性作爲證書嗎?此方案是否適用於basicHttpBinding?我聽說basicHttpBinding不能通過證書獲得消息安全。

在這方面的任何幫助,將不勝感激。

這是我在服務中的服務模型。

<system.serviceModel> 
<client>  
    <endpoint behaviorConfiguration="" 
    binding="basicHttpBinding" 
     bindingConfiguration="WCFServiceX509Binding" 
    contract="WCFService.Contract.Service.IWCFServiceContract" 
     name="WCFServiceClientEndPoint" />  
</client> 
<bindings> 
    <basicHttpBinding> 
    <binding name="WCFServiceX509Binding" maxBufferSize="6553600" 
     maxBufferPoolSize="52428800" maxReceivedMessageSize="6553600"> 
     <security mode="TransportWithMessageCredential"> 
     <transport clientCredentialType="Certificate" /> 
     <message clientCredentialType="Certificate" /> 
     </security> 
    </binding>   
    </basicHttpBinding> 
</bindings> 
<services> 
    <service behaviorConfiguration="ServiceBehavior" 
    name="WCFService.Model.WCFServiceModel"> 
    <endpoint 
    address="" 
    binding="basicHttpBinding" 
    bindingConfiguration="WCFServiceX509Binding" 
     name="WCFServiceBasicHttpEndPoint" 
    contract="WCFService.Contract.Service.IWCFServiceContract"> 
     <identity> 
      <certificateReference findValue="WCFUADOCServer" /> 
     </identity> 
    </endpoint> 
    </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="ServiceBehavior"> 
     <serviceMetadata httpGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="true" /> 
     <serviceCredentials /> 
    </behavior> 
    </serviceBehaviors> 
    <endpointBehaviors> 
    <behavior name="ClientCertificateBehavior"> 
     <clientCredentials> 
     <clientCertificate findValue="WCFUADOCServer" 
        x509FindType="FindBySubjectName" 
        storeLocation="LocalMachine" 
        storeName="TrustedPeople" /> 
     </clientCredentials> 
    </behavior> 
    </endpointBehaviors> 
</behaviors> 

太感謝了, 昌德。

回答

0
  1. Mex端點不依賴證書。根據您的配置,您根本不公開mex endpoint,並且幫助WSDL的頁面仍然可以通過HTTP訪問。
  2. 你想做什麼?安全有點high level term in this case。您可以使用安全的傳輸通道,並且可以使用郵件中傳輸的證書進行身份驗證(我從未嘗試過這種組合)。該方案應該在BasicHttpBinding以上。我自己感到驚訝,但BasicHttpBinding實際上支持完整的相互證書不對稱的消息安全。

如果要公開與運輸安全的服務,你必須使用HTTPS - 由IIS management console無論是配置(在IIS託管時)或assign certificate to port by netsh(自託管)。請注意,運行該服務的帳戶必須有權訪問證書中的私鑰 - you must correctly set up ACL

如果要通過證書驗證客戶端,則應設置service credentials。如果您使用的放置到證書存儲區的自簽名的證書,你至少應該使用這樣的:

<serviceCredentials> 
    <clientCertificate> 
    <authentication certificateValidationMode="PeerTrust" /> 
    </clientCertificate> 
</serviceCredentials> 

您還可以定義custom certificate validator。對於端點使用寧可dns身份。

對於客戶端也使用服務證書的PeerTrust驗證模式。

+0

哇,這是快...真棒引用。是的,安全性非常高。基本上它帶有非常敏感的信息,因此我必須同時具有傳輸和消息安全性。 – Chandanan 2011-04-27 20:49:38

+0

我會盡力做你所建議的所有事情,並會再次回覆你。非常感謝答覆。關心,Chand。 – Chandanan 2011-04-27 20:53:37

+0

我忘了發佈關於「高層次術語」的額外鏈接。我修改了我的答案。 – 2011-04-27 20:54:07