我正在开发一个WCF服务(NetTcpBinding),它在没有安全性的情况下可以正常工作。我们从DigiCert购买了一个证书,并将其安装在服务器上,并配置了DigicertUtil.exe. 也安装在测试客户机上。
打开安全性,我可以从我的开发人员PC连接到它没有问题。
服务器配置:
binding.Security.Mode = SecurityMode.Transport;
binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate;
binding.Security.Transport.ProtectionLevel = ProtectionLevel.EncryptAndSign;
ServerHost.Credentials.ServiceCertificate.SetCertificate(
StoreLocation.LocalMachine,
StoreName.My,
X509FindType.FindBySubjectName,
Properties.Settings.Default.CertificateName);
客户端配置:
<binding name="EndPointTCP" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false"
hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="1610612736"
maxReceivedMessageSize="1610612736">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="false" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Certificate" protectionLevel="EncryptAndSign"/>
</security>
</binding>
<behaviors>
<endpointBehaviors>
<behavior name="behavior_ServerService">
<clientCredentials>
<clientCertificate findValue="*.domain.com"
storeLocation="LocalMachine"
storeName="My"
x509FindType="FindBySubjectName" />
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint address="net.tcp://clients.domain.com:10001/Server/ServerService"
binding="netTcpBinding" bindingConfiguration="EndPointTCP" contract="ServerServiceReference.IServerWS"
name="EndPointTCP" behaviorConfiguration="behavior_ServerService">
<identity>
<dns value="*.domain.com" />
</identity>
</endpoint>
</client>
从任何其他计算机尝试时,我在客户端上收到以下错误:
套接字连接已中止。这可能是由于处理消息时出错、远程主机超过接收超时或底层网络资源问题造成的。本地套接字超时为“00:00:59.9840000”。
远程主机已强制关闭现有连接
服务器上的跟踪日志显示:
根据验证过程,远程证书无效。
这很奇怪,因为我在服务器和客户端上使用相同的证书(更不用说它运行良好的dev pc了……)
即使我设置了
ServerHost.Credentials.ClientCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
ServiceClient.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
在客户身上。
谁能告诉我怎么做才对吗?当然,我不想使用诸如验证回调总是返回true或上述未验证模式之类的解决方法。
任何帮助都将不胜感激。只有解决这个“小”问题才能释放…:(
提前多谢了!