【问题标题】:Using Wcf SSl certificate over Tcp without client certificate (Server side only)在没有客户端证书的情况下通过 Tcp 使用 Wcf Ssl 证书(仅限服务器端)
【发布时间】:2012-06-07 21:34:21
【问题描述】:

有没有什么方法可以将 WCF SSL 与 NetTcpBinding 一起使用,而不需要在客户端计算机上安装客户端证书? (如果我没记错的话,SSL V2)。

我们希望服务器证书将在客户端的可信存储中进行身份验证 并通过服务器的公钥加密其消息,这意味着只有服务器机器将持有私钥证书。

我们在双方都使用 NetTcpBinding 而不是 customBinding。 如果它可以完成,它的正确配置是什么? (在客户端和服务器配置上)

提前致谢。


这是我的 wcf 配置。

服务器配置:



    <configuration>
      <system.serviceModel>
        <bindings>
         <netTcpBinding>
            <binding name="TcpSecureBinding">
            <security mode="Transport">
              <transport clientCredentialType="Certificate"/>            
            </security>
       </binding>
         </netTcpBinding>
       </bindings>
       <behaviors>
         <serviceBehaviors>
           <behavior name="ServiceCredentialsBehavior">          
             <serviceDebug includeExceptionDetailInFaults="True" />
             <serviceMetadata httpGetEnabled="true" />
             <serviceAuthorization 
                 principalPermissionMode="UseWindowsGroups">
             </serviceAuthorization>
          <serviceCredentials>
               <windowsAuthentication includeWindowsGruops="true"            
                                      allowAnonymousLogons="false"/>
               <clientCertificate>
                     <authentication certificateValidationMode="none"/>
               </clientCertificate>
               <serverCertificate
                   findValue="thumbprint"
                   storelocation="LocalMachine"
                   x509FindType="FindMyThumbprint"
                   storeName="My"/>
           </serviceCredentials>
        </behavior>
       </serviceBehaviors>
      </behaviors>
    <services>
        <service behaviorConfiguration="ServiceCredentialsBehavior"
               name="ServiceModel.Calculator">
          <endpoint address="net.tcp://localhost:8040/Calculator"
                  binding="netTcpBinding"
                  bindingConfiguration="TcpSecureBinding"
                  contract="ServiceModel.ICalculator" >
           <identity>
               <dns value="localhost"/>
           </identity>
         </endpoint>
        </service>
     </services>
    </system.serviceModel>
    </configuration>

客户端配置:



    <configuration>
      <system.serviceModel>
        <client>
         <endpoint address="net.tcp://localhost:8040/Calculator"
                behaviorConfiguration="endpointCredentialBehavior"
                binding="netTcpBinding" 
                bindingConfiguration="Binding1" 
                contract="ServiceModel.ICalculator">
          <identity>
               <dns value="localhost"/>
          </identity>
          </endpoint>
        </client>
      <behaviors>
        <endpointBehaviors>
          <behavior name="endpointCredentialBehavior">
          </behavior>
         </endpointBehaviors>
       </behaviors>
       <bindings>
         <netTcpBinding>
          <binding name="Binding1">
            <security mode="Transport">
              <transport clientCredentialType="Windows" />
             </security>
          </binding>
          </netTcpBinding>
        </bindings>
     </system.serviceModel>
    </configuration>

我正在添加我当前的服务器和客户端配置。 另一个问题:

  1. 在身份验证级别,我们希望客户端对服务器的证书进行身份验证 (我认为服务器的公钥应该在trustedPeople存储中),这可能吗?

  2. 您是否建议我们使用传输安全或消息?

  3. 如果我们想通过 NTLM 验证客户端和服务器 (clientCredentialType=Windows) 除了服务器的证书身份验证之外,它还可以完成还是只能应用其中之一? 到目前为止,我们使用的是 NTLM 身份验证。

  4. 现在我遇到异常: “'net.tcp://servername:8040/**' 不支持请求的升级。这可能是由于绑定不匹配(例如,在客户端而不是在服务器上启用了安全性) )。” 我了解发生此错误是因为客户端在 om 证书中使用 Windows 安全和服务器, 但是当我将客户端安全性也更改为证书时,我得到一个错误: “未提供客户端证书”。但我不想设置客户的证书,这是我主要问题的一部分。

  5. 我们读到我们可以将这个标签用于服务器的证书身份验证:

    
        <identity>
          <certificate encodedValue="encoded certificate"/>
        </identity>
    

但是,我认为这种身份验证是通过编码证书完成的,当我们希望通过在客户端存储(trustedPeople)中搜索服务器的公钥来执行证书的识别时。这些信息真的是真的吗?这种身份标签可以替代在客户的受信任商店中搜索公钥吗?

希望您能够以这种方式提供帮助, 再次感谢。

【问题讨论】:

  • 有可能。到目前为止,您尝试过什么?
  • 除非您特别要求,否则您不需要客户端证书;你的绑定配置是什么样的?
  • 有人可以帮我解决我们的问题吗??

标签: wcf ssl https certificate


【解决方案1】:

如果您正在使用 netTcpBiding 并且需要使用传输安全性,那么您有 3 个选项,第一个选项需要服务证书,第二个根本不需要证书,第三个需要服务证书和客户端证书。对于您的场景,您应该使用 option1 来通过它的证书对服务进行身份验证,并为消息提供机密性和完整性。

C >> 保密
我 >> 诚信
A >> 身份验证(这将发生在客户端)

1- 选项一提供 (C + I) 不会对客户端进行身份验证,在这种情况下,将使用 TCP SSL(不是 HTPS SSL)来提供 C 和 I,并且服务将是

<!--//Below are the configuration for both the service and the client-->
<netTcpBinding>
    <binding name="TcpSecureBinding">
      <security mode="Transport">
        <transport clientCredentialType="None"></transport>
      </security>
    </binding>
  </netTcpBinding>

也因为会使用TCP SSL,所以服务必须为客户端提供证书,所以你需要在服务端安装一个证书,并配置服务使用这个证书来证明自己的身份,你也需要安装客户端计算机上服务证书的根证书颁发机构证书(通常在 LocalMachine/Trusted Root Certification Authorities 中),并且服务需要具有以下行为来指定服务的证书

<serviceBehaviors>
    <behavior>
      <serviceCredentials>
        <serviceCertificate findValue="localhost"
                            x509FindType="FindByIssuerName" />
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>

2- 选项二提供 (A+ [C + I]),当您通过 protectionLevel 元素配置时,C 和 I 是可选的。客户端身份验证将是 windows 身份验证(通常会使用 Windows Stream Security 来实现 A、C 和 I)

<!--//Below are the configuration for both the service and the client-->
<netTcpBinding>
    <binding name="TcpSecureBinding">
      <security mode="Transport">
        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"></transport>
      </security>
    </binding>
  </netTcpBinding>

3-选项3提供(A + C + I),C和I不是可选的,客户端身份验证将通过客户端证书(每个客户端必须有自己的证书), 在这种情况下,TCP SSL(不是 HTPS SSL)将用于提供 A、C 和 I。

<!--//Below are the configuration for both the service and the client-->
<binding name="TcpSecureBinding">
      <security mode="Transport">
        <transport clientCredentialType="Certificate"></transport>
      </security>
    </binding>

也因为会使用TCP SSL,所以服务必须为客户端提供证书,所以你需要在服务端安装一个证书,并配置服务使用这个证书来证明自己的身份,你也需要安装客户端计算机上服务证书的根证书颁发机构证书(通常在 LocalMachine/Trusted Root Certification Authorities 中),并且服务需要具有以下行为来指定服务的证书

<serviceBehaviors>
    <behavior>
      <serviceCredentials>
        <serviceCertificate findValue="localhost"
                            x509FindType="FindByIssuerName" />
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>

【讨论】:

  • 客户端端点配置需要是什么样子才能仅使用公共根 CA 密钥?我一直在尝试使用由根 CA 签名的机器证书来配置我的服务,但是当我将客户端配置为使用根 CA 时,客户端和服务器无法通信。但是,当我将服务机器证书的公钥放在客户端上(并将“findValue”更改为该证书名称)时,它就可以工作了。我做错了什么?
猜你喜欢
  • 1970-01-01
  • 2020-08-05
  • 1970-01-01
  • 2015-10-20
  • 2011-08-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-23
相关资源
最近更新 更多