【发布时间】:2011-03-28 01:22:25
【问题描述】:
我正在开发 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”。
现有连接被远程主机强行关闭
服务器上的跟踪日志显示:
根据验证程序,远程证书无效。
这很奇怪,因为我在服务器和客户端上都使用相同的证书......(更不用说运行良好的开发电脑......)
即使我设置了错误信息也是一样的
ServerHost.Credentials.ClientCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
在服务器上和
ServiceClient.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
在客户端。
谁能告诉我如何正确地做到这一点?当然,我不想使用验证回调总是返回 true 或上述非验证模式等变通方法。
任何帮助将不胜感激。只有解决这个“小”问题才能发布...... :(
提前非常感谢!
哈吉
【问题讨论】:
-
stackoverflow.com/questions/777607/… 复制粘贴 1 行和 kaboom :)
标签: wcf validation certificate