簡體   English   中英

在沒有客戶端證書的情況下在Tcp上使用Wcf SSl證書(僅限服務器端)

[英]Using Wcf SSl certificate over Tcp without client certificate (Server side only)

有沒有辦法使用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)除了服務器的cert身份驗證之外還可以執行它還是只能應用其中一個? 到目前為止,我們已經使用過NTLM身份驗證。

  4. 現在我得到異常:“'net.tcp:// servername:8040 / ** '不支持請求的升級。這可能是由於綁定不匹配(例如客戶端而不是服務器上啟用了安全性) “。 我理解這個錯誤發生,因為客戶端使用Windows安全和服務器在om證書,但當我也將客戶端安全性更改為證書時,我得到一個錯誤:“沒有提供客戶端證書”。 但我不想設置客戶的證書,這是我主要問題的一部分。

  5. 我們讀到我們可以使用服務器的證書認證這個標簽:

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

但是,我認為當我們通過在客戶端的商店(trustedPeople)中搜索服務器的公鑰來執行證書的身份驗證時,身份驗證是通過編碼證書完成的。 這些信息真的如此嗎? 這個身份標簽是否可以替代客戶信任的商店中的公鑰?

希望你能夠以這種方式提供幫助,再次感謝。

你正在使用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 /受信任的根證書頒發機構中),並且服務需要具有以下行為來指定服務的證書

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

2-選項二提供(A + [C + I]),當您通過protectionLevel元素配置時,C和I是可選的。 客戶端auth將是windows auth(通常會使用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 /受信任的根證書頒發機構中),並且服務需要具有以下行為來指定服務的證書

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM