在Tcp上使用Wcf SSL证书,无需客户端证书(仅服务器端)

5
有没有一种使用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. at the authentication level we want the client to authenticate ther server's cert (i think server's public key should be in trustedPeople store) , is this possible?

  2. do you recommend us use Transport Security Or Message?

  3. if we want to authenticate client & server by NTLM (clientCredentialType=Windows) is it can be done in addition to the server's cert authentication or just one of them can be applied? till now, we've used NTLM authentication.

  4. right now im getting exception: "The requested upgrade is not supported by 'net.tcp://servername:8040/**'. This could be due to mismatched bindings (for example security enabled on the client and not on the server)." i understand this error occured because the client is using Windows Security and server in om Certificate, but when im changing client security to Certificate also,im getting an error: "The client certificate is not provided". but i don't want to set client's certificate and thats part of my main problem.

  5. we read that we can use for server's cert authentication this tags:

    
        <identity>
          <certificate encodedValue="encoded certificate"/>
        </identity>
    
但是,我认为身份验证是通过编码证书完成的,当我们希望证书的识别是通过在客户端的存储(trustedPeople)中搜索服务器的公钥来执行时。这个信息真的正确吗?这些身份标签是替代在客户端的受信任存储中搜索公钥的方法吗?感谢您的帮助。

可以实现。你目前尝试了什么? - Bernard
除非您明确要求,否则不应需要客户端证书;您的绑定配置是什么样子? - Michael Edenfield
有人能帮忙解决我们的问题吗? - AmirT
1个回答

13
如果您正在使用netTcpBinding并需要使用传输安全,则有3种选项,第一种选项需要服务证书,第二种选项根本不需要证书,第三种选项需要服务证书和客户端证书。对于您的情况,应该使用选项1,它将通过其证书对服务进行身份验证,并为消息提供机密性和完整性。
C >> 机密性
I >> 完整性
A >> 身份验证(将在客户端发生)
1- 选项一提供了(C + I),客户端不需要进行身份验证,在这种情况下将使用TCP SSL(而不是HTTP 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>

第二个选项提供(A+ [C + I]),C和I是可选的,并且可以通过protectionLevel元素进行配置。客户端认证将是Windows认证(通常使用Windows流安全性来实现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>

第三种选项提供(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”更改为该证书的名称),然后它就可以工作了。 我做错了什么? - Simon Gillbee

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接