2015-05-04 78 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不检查特定证书的撤销列表。 –