2015-05-04 79 views
1

此使用NetTcpBinding的自考託管服務配置傳輸安全性是在服務端配置:異常在WCF

<endpoint binding="netTcpBinding" bindingConfiguration="TcpBinding" contract="a"></endpoint> 
<binding name="TcpBinding"> 
    <security mode="Transport"> 
    <transport protectionLevel="EncryptAndSign" clientCredentialType="None"> 
    </transport> 
    </security> 
    <reliableSession enabled="false"/> 
</binding> 

<serviceBehaviors> 
<behavior> 
    <serviceCredentials> 
    <serviceCertificate storeName="My" storeLocation="LocalMachine" findValue="73 b9 d8 98 8d b6 54 bf fb ff 21 0b ac fc 04 19 37 16 71 5f" x509FindType="FindByThumbprint" /> 
    </serviceCredentials> 
    <serviceMetadata httpGetEnabled="false"/> 
    <serviceDebug includeExceptionDetailInFaults="true"/> 
</behavior> 
</serviceBehaviors> 

我創建了以下鏈接自簽名證書: https://msdn.microsoft.com/en-us/library/ff648498.aspx

第一我創建了一個證書,將其作爲根證書頒發機構安裝在受信任的根證書頒發機構中 - 名爲「RootCA」。然後,我創建了另一個自簽名證書,簽發給'LocalCA'的'RootCA'。

在客戶端,我使用與服務端相同的配置元素。當您打開代理,我收到以下異常:

System.ServiceModel.Security.SecurityNegotiationException的X.509證書 CN =本地主機鏈構建失敗。使用 的證書具有無法驗證的信任鏈。替換 證書或更改certificateValidationMode。撤銷 函數無法檢查證書的撤銷。

還有什麼需要讓這個運行?

回答

1
include this in your client side in endpoint behaviours 

    <endpointBehaviors> 
      <behavior name="clientBehave"> 
      <clientCredentials> 
       <serviceCertificate>    
<authentication certificateValidationMode="PeerOrChainTrust" revocationMode="NoCheck"/> 
       </serviceCertificate> 
      </clientCredentials> 
      </behavior> 
     </endpointBehaviors> 
+0

如果您正在使用的客戶端證書也那麼做,在服務器端也爲服務行爲同樣的事情 - serviceCredentials –

+0

撤銷模式用於檢查證書是否仍然有效,意味着該CA還沒有撤銷使用證書。證書管理器中有一個證書吊銷列表文件夾,與展開證書存儲區時的證書文件夾一樣。它包含特定發行人的撤銷清單。 –

+0

將revocationMode設置爲NoCheck將使WCF不檢查特定證書的撤銷列表。 –