根据验证程序,远程证书无效

问题描述:

我正在开发一个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> 

从任何其他计算机尝试它我在客户端收到以下错误:

The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.9840000'.

An existing connection was forcibly closed by the remote host

服务器上的跟踪日志说:

The remote certificate is invalid according to the validation procedure.

,因为我使用的服务器和客户端使用相同的证书,这是非常奇怪的......(别说dev的PC从它的工作好...)

错误信息是一样的,即使我设置

ServerHost.Credentials.ClientCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None; 
在服务器上

ServiceClient.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None; 

在客户端上。

有人能告诉我如何正确地做到这一点吗?当然,我不想使用变通方法,比如验证回调总是返回true或者上面的未验证模式。

任何帮助,将不胜感激。只有这个“小”问题应该得到解决,以便能够释放... :(

非常感谢事先!

Hudgi

+0

http:// stackoverflow。COM /问题/ 777607 /的远程证书 - 是 - 根据到的验证无效 - - 程序-PLE 复制粘贴1线和KABOOM :) – ariel 2012-03-07 09:14:01

这听起来像你正在尝试使用相同的证书无论是服务器还是客户端证书,并且您的客户端没有与颁发证书的主机名相同的主机名即使您设置了X509CertificateValidationMode.None,主机名也必须匹配如果您的开发机器与服务器相同,成功

您是否故意尝试让客户端进行身份验证通过SSL连接到服务器,还是只是试图通过证书颁发机构建立对客户的信任?

我还怀疑你的证书可能不是真正的通配符证书,如果这是你运气不好的情况下使用该证书进行客户端验证。

+0

平淡嗨, 我怎么能检查证书是通配符还是不是? 在主题备用名称字段我有simlar这个值: DNS名称= clients.domain.com DNS名称= domain.com DNS名称= * domain.com 开发商机是我的笔记本电脑和服务器是与其他测试PC相似的另一个VPN。 我需要一种不强制主机名与服务器相同的方式,因为我们希望稍后在世界上的许多机器上运行客户端。我在服务器和客户端配置文件中都向端点添加了子句。这不够吗? Thx。 – Hudgi 2010-08-11 09:51:12

+0

如果您没有证书进行备份,只更改标识元素是不够的。你说你有* .domain.com ..其中包括myClient.domain.com,但我不认为通配符会支持像myClient.clients.domain.com这样的子域名。你的客户是否在一个子域? – insipid 2010-08-11 14:18:19

+0

我们计划允许客户访问世界各地的服务,所以我们不能指望他们拥有相同的域名。我们希望将客户端软件安装在远程计算机上并自动将其作为服务运行。我们只是想对客户端和服务器之间的通信进行加密,因为它通过互联网发送敏感数据。 服务器的地址是clients.domain.com(当然它不是真正的地址,但显示了子域的深度),我们根本不知道客户端地址。可以做到吗? – Hudgi 2010-08-11 15:05:36