Client

<< Klicken Sie hier um das Inhaltsverzeichnis anzuzeigen >>

Navigation:  Konfiguration > Kommunikation >

Client

Damit ein Modul (Client) eine Verbindung zum DABiS Server aufbauen kann, muss der Client entsprechend konfiguriert werden. In einigen Modulen werden diese Einstellungen in der App.config des entsprechenden Moduls vorgenommen. Dazu folgt nun ein Beispiel. Für die spezifische Client Konfiguration lesen Sie jedoch bitte die Hilfe des entsprechenden Moduls.

 

Konfigurieren der Server-Endpoints:

Als erstes muss die Serveradresse konfiguriert werden. Diese wird im Attribug <client><endpoint ...> angegeben und muss für beide dort konfigurierten Endpoints (DabisServer und DabisFileTransferService) unter dem Attribut address="net.tcp://dabis-naz2010:8000/DabisServer" gemacht werden. Standardmässig läuft der DabisServer-EndPoint auf Port 8000 und der DabisFileTransferService auf Port 8006.

 

Konfigurieren des Zertifikats:

Die Verbindung vom Client und Server wird über ein Zertifikat authentifiziert und verschlüsselt. Dabei liegt das Zertifikat auf dem Filesystem und wird direkt vom Client eingelesen. Damit der Client weiss wo er das Zertifikat findet, muss dies in der Konfiguration festgelegt werden. Dies geschieht in der Section <sohard.dabis.connection.cert>. Dort wird für jeden Endpoint das Client-Zertifikat im Attribut clientCertificate="Pfad|Passwort" eingestellt (Pfad|Passwort). Es muss sichergestellt sein, dass der Client Zugriff auf diesen Pfad hat (wichtig bei UNC-Pfad). Damit die Section <sohard.dabis.connection.cert> erkannt wird muss diese vorgängig in der Section <configSections> hinzugefügt werden <section name="sohard.dabis.connection.cert" type="Sohard.Dabis.Connection.Cert.Configuration.Section, DabisConnection" />

 

Beispiel WCF-Konfiguration Client:

 

 <configSections>

   <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>

   <section name="sohard.dabis.connection.cert" type="Sohard.Dabis.Connection.Cert.Configuration.Section, DabisConnection"/>

 </configSections>

 

 <system.serviceModel>

   <client>

     <endpoint name="DabisServer"

              address="net.tcp://localhost:8000/DabisServer"

              binding="netTcpBinding"

              bindingConfiguration="DabisServerBinding"

              contract="Sohard.Dabis.ServiceContracts.IServerContract"

              behaviorConfiguration="ClientEndpointBehavior">

       <identity>

         <certificate encodedValue="MIIDKzCCAhOgAwIBAgIQMgyQ7CNXuaFGGs2OCwzP0jANBgkqhkiG9w0BAQsFADAk

         MQ4wDAYDVQQLEwVEQUJpUzESMBAGA1UEAxMJU09IQVJEIEFHMB4XDTE1MTIzMTIz

         MDAwMFoXDTM5MTIzMTIzMDAwMFowJDEOMAwGA1UECxMFREFCaVMxEjAQBgNVBAMT

         CVNPSEFSRCBBRzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMUStpVd

         uTLQX8yAMNos/BW6/eFcqwyn/NgTqYtZilnTefSv/VeuRAIMhs6j/l7Jsn8K+reP

         FoJAEbnK+4UWmXrXXJ//nm/Ts7rvurvFoIsgV84Vp2yCQ4SsH4UEfK6plojbw17Z

         qhczTQUsePA+0lB5rRf7/A6BFLvw5lunCqLiY+WQEQmuJamSVv5rCkxWYSKXTZco

         7R/ZE1+Im3YC12vFTcO00L/zYSk4LqbwU0Yvnn0BtqxS+4UdFIwEIOc9nyXjjpO6

         4Ns+jXr01ugM6LbGcOPhFRmW3UTgxOdZ6WutLDEQVxdwLS7lAZShhAx4LBJhMPLo

         bfVca4MfC/3uw0kCAwEAAaNZMFcwVQYDVR0BBE4wTIAQYtF2rOrz4XmyxliFpoBI

         cKEmMCQxDjAMBgNVBAsTBURBQmlTMRIwEAYDVQQDEwlTT0hBUkQgQUeCEDIMkOwj

         V7mhRhrNjgsMz9IwDQYJKoZIhvcNAQELBQADggEBALZv30donfaErPYhbjWjTQii

         uyBCAtd1ZDDuv2O3qdZBNuby4FVOr4PklMgxglNyTwU5mCta+lt4Tvgw9os42hBn

         X08CiRmgOWFWgmLpfTkMc4LobPMvasUDW/RJNtX3ZE6u0FSAS6a7e89+DLI204+k

         FZADGNQW5PoOCRzEGM/M4mPTR98lBIg4uWIAKchc24chefQC0a/M28EoVZbo5hEM

         F2rjOborGJ51/tAs8JHLSTQIopKDNjU9SJBFIQ6qzd0yWheloQzxi2aIn7K+BZ5b

         T7Kan8ym46bGcR4ty10A4Pr+o14BfaZCPznXYSWn4+FweFA+p9R56EiuJEYK2h4="/>

       </identity>

     </endpoint>

     <endpoint name="DabisFileTransferService"

              address="net.tcp://localhost:8006/DabisFileTransferService"

              binding="netTcpBinding"

              bindingConfiguration="DabisStreamingBinding"

              contract="Sohard.Dabis.ServiceContracts.IServiceContractFileTransfer"

              behaviorConfiguration="ClientEndpointBehavior">

       <identity>

         <certificate encodedValue="MIIDKzCCAhOgAwIBAgIQMgyQ7CNXuaFGGs2OCwzP0jANBgkqhkiG9w0BAQsFADAk

         MQ4wDAYDVQQLEwVEQUJpUzESMBAGA1UEAxMJU09IQVJEIEFHMB4XDTE1MTIzMTIz

         MDAwMFoXDTM5MTIzMTIzMDAwMFowJDEOMAwGA1UECxMFREFCaVMxEjAQBgNVBAMT

         CVNPSEFSRCBBRzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMUStpVd

         uTLQX8yAMNos/BW6/eFcqwyn/NgTqYtZilnTefSv/VeuRAIMhs6j/l7Jsn8K+reP

         FoJAEbnK+4UWmXrXXJ//nm/Ts7rvurvFoIsgV84Vp2yCQ4SsH4UEfK6plojbw17Z

         qhczTQUsePA+0lB5rRf7/A6BFLvw5lunCqLiY+WQEQmuJamSVv5rCkxWYSKXTZco

         7R/ZE1+Im3YC12vFTcO00L/zYSk4LqbwU0Yvnn0BtqxS+4UdFIwEIOc9nyXjjpO6

         4Ns+jXr01ugM6LbGcOPhFRmW3UTgxOdZ6WutLDEQVxdwLS7lAZShhAx4LBJhMPLo

         bfVca4MfC/3uw0kCAwEAAaNZMFcwVQYDVR0BBE4wTIAQYtF2rOrz4XmyxliFpoBI

         cKEmMCQxDjAMBgNVBAsTBURBQmlTMRIwEAYDVQQDEwlTT0hBUkQgQUeCEDIMkOwj

         V7mhRhrNjgsMz9IwDQYJKoZIhvcNAQELBQADggEBALZv30donfaErPYhbjWjTQii

         uyBCAtd1ZDDuv2O3qdZBNuby4FVOr4PklMgxglNyTwU5mCta+lt4Tvgw9os42hBn

         X08CiRmgOWFWgmLpfTkMc4LobPMvasUDW/RJNtX3ZE6u0FSAS6a7e89+DLI204+k

         FZADGNQW5PoOCRzEGM/M4mPTR98lBIg4uWIAKchc24chefQC0a/M28EoVZbo5hEM

         F2rjOborGJ51/tAs8JHLSTQIopKDNjU9SJBFIQ6qzd0yWheloQzxi2aIn7K+BZ5b

         T7Kan8ym46bGcR4ty10A4Pr+o14BfaZCPznXYSWn4+FweFA+p9R56EiuJEYK2h4="/>

       </identity>

     </endpoint>

   </client>

   

   <bindings>

     <netTcpBinding>

       <binding name="DabisServerBinding"

                closeTimeout="00:01:00"

                openTimeout="00:01:00"

                receiveTimeout="00:10:00"

                sendTimeout="00:01:00"

                transactionFlow="true"

                transferMode="Buffered"

                transactionProtocol="OleTransactions"

                hostNameComparisonMode="StrongWildcard"

                listenBacklog="10"

                maxBufferPoolSize="2147483647"

                maxBufferSize="2147483647"

                maxConnections="10"

                maxReceivedMessageSize="2147483647">

         <readerQuotas maxDepth="32"

                      maxStringContentLength="2147483647"

                      maxArrayLength="2147483647"

                      maxBytesPerRead="8192"

                      maxNameTableCharCount="16384"/>

         <reliableSession ordered="true"

                          inactivityTimeout="00:10:00"

                          enabled="false"/>

         <security mode="Transport">

           <transport clientCredentialType="Certificate"

                      protectionLevel="EncryptAndSign"></transport>

           <message clientCredentialType="Certificate"/>

         </security>

       </binding>

       

       <binding name="DabisStreamingBinding"

                transferMode="Streamed"

                maxBufferSize="2147483647"

                maxReceivedMessageSize="2147483647"

                transactionFlow="true">

         <readerQuotas maxDepth="32"

                      maxStringContentLength="2147483647"

                      maxArrayLength="2147483647"

                      maxBytesPerRead="8192"

                      maxNameTableCharCount="16384"/>

         <security mode="Transport">

           <transport clientCredentialType="Certificate"

                      protectionLevel="EncryptAndSign"/>

           <message clientCredentialType="Certificate"/>

         </security>

       </binding>

     </netTcpBinding>

   </bindings>

 

   <behaviors>

     <endpointBehaviors>

       <behavior name="ClientEndpointBehavior">

         <dataContractSerializer maxItemsInObjectGraph="2147483647"/>

         <clientCredentials>

           <serviceCertificate>

             <!--

               Setting the certificateValidationMode to PeerOrChainTrust means that if the certificate

               is in the user's Trusted People store, then it will be trusted without performing a

               validation of the certificate's issuer chain. This setting is used here for convenience so that the

               sample can be run without having to have certificates issued by a certificate authority (CA).

               This setting is less secure than the default, ChainTrust. The security implications of this

               setting should be carefully considered before using PeerOrChainTrust in production code.

              -->

             <authentication certificateValidationMode="None"/>

           </serviceCertificate>

         </clientCredentials>

       </behavior>

     </endpointBehaviors>

   </behaviors>

 </system.serviceModel>

 

 <sohard.dabis.connection.cert>

   <endPoints>

     <add contract="DabisServer" clientCertificate="certificates\DabisServer.pfx|wcf" />

     <add contract="DabisFileTransferService" clientCertificate="certificates\DabisServer.pfx|wcf" />

   </endPoints>

 </sohard.dabis.connection.cert>