2012-03-13 2 views
3

Мне нужно создать услугу «маршрутизации». Я пытаюсь использовать System.ServiceModel.Routing.IRequestReplyRouter .Net Я могу заставить его работать только в режиме HTTP, а не в HTTPS. Ошибка: «Не удается установить безопасное соединение SSL/TLS» ... Я также попробовал собственный сертификат проверки подлинности, но он не вызывается! (Он будет создан, но метод проверки не называется)WCF routing + SSL

я отправляю мою конфигурацию здесь:

<?xml version="1.0"?> 

<bindings> 

     <customBinding> 
      <!-- Security Off version--> 
      <binding name="customBindingNotSecure"> 
       <textMessageEncoding messageVersion="Soap12WSAddressing10"/> 
       <httpTransport /> 
      </binding> 

      <!-- Security On --> 
      <binding name="customBindingSecure"> 

       <textMessageEncoding messageVersion="Soap12WSAddressing10"> 
       </textMessageEncoding> 
       <security authenticationMode="UserNameOverTransport" /> 
       <httpsTransport /> 
      </binding> 

      <binding name="platoneBinding"> 
       <textMessageEncoding messageVersion="Soap12WSAddressing10" /> 
       <httpsTransport maxReceivedMessageSize="1000000" maxBufferPoolSize="1000000" maxBufferSize="1000000" /> 
      </binding> 

     </customBinding> 


    </bindings> 

    <services> 
     <service behaviorConfiguration="routingService" name="System.ServiceModel.Routing.RoutingService"> 
      <endpoint address="" 
       binding="customBinding" 
       name="reqReplyEndpoint" 
       contract="System.ServiceModel.Routing.IRequestReplyRouter" bindingConfiguration="customBindingSecure"/> 

      <endpoint address="" 
       binding="customBinding" 
       name="reqReplyEndpointHttp" 
       contract="System.ServiceModel.Routing.IRequestReplyRouter" 
    bindingConfiguration="customBindingNotSecure"/> 

     </service> 


    </services> 
    <behaviors> 

     <endpointBehaviors> 
      <behavior name="CustomClientBehavior"> 
       <clientCredentials> 
        <serviceCertificate> 
         <defaultCertificate findValue="serverx509v1" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName"/> 
         <authentication customCertificateValidatorType="com.abodata.plat1.WCFProxy.PlatoneCertificateValidator, PlatoneWSRelay" 
         certificateValidationMode="Custom" revocationMode="NoCheck" /> 
        </serviceCertificate> 
       </clientCredentials> 
      </behavior> 
     </endpointBehaviors> 

     <serviceBehaviors> 
      <behavior name="routingService"> 
       <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> 
       <serviceDebug includeExceptionDetailInFaults="true" /> 
       <routing routeOnHeadersOnly="true" filterTableName="routingTable1" /> 
       <serviceCredentials> 

        <clientCertificate> 

         <authentication customCertificateValidatorType="com.abodata.plat1.WCFProxy.PlatoneCertificateValidator, PlatoneWSRelay" 
         certificateValidationMode="Custom" revocationMode="NoCheck" /> 
        </clientCertificate> 
        <userNameAuthentication userNamePasswordValidationMode="Custom" 
        customUserNamePasswordValidatorType="com.abodata.plat1.WCFProxy.UsernameValidator, PlatoneWSRelay" /> 

       </serviceCredentials> 

      </behavior> 

      <behavior name=""> 
       <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> 
       <serviceDebug includeExceptionDetailInFaults="true" /> 
      </behavior> 


     </serviceBehaviors> 
    </behaviors> 

    <routing> 
     <filters> 
      <filter name="MatchAllFilter1" filterType="MatchAll" /> 
     </filters> 
     <filterTables> 
      <filterTable name="routingTable1"> 
       <add filterName="MatchAllFilter1" endpointName="PlatoneWSService" /> 
      </filterTable> 
     </filterTables> 

    </routing> 

    <client> 
     <endpoint address="https://10.0.2.243:9006/Persistence" 
     binding="customBinding" bindingConfiguration="platoneBinding" 
     contract="*" name="PlatoneWSService"> 

      <identity> 
<dns value="serverx509v1" /> 
</identity> 
     </endpoint> 
    </client> 


    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
</system.serviceModel> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
</system.webServer> 

EDIT: Мне удалось установить соединение TLS добавив в мою конфигурацию

<system.net> 
    <settings> 
     <servicePointManager checkCertificateName="false" checkCertificateRevocationList="false"/> 
    </settings> 
</system.net> 

Но ... теперь у меня проблемы с заголовком безопасности моего конверта с мылом. Клиент правильно отправляет сообщение моему маршрутизатору, но он удаляет заголовок безопасности, поэтому я получаю исключение ...

+0

Вы работали с безопасные службы WCF раньше? – Bernard

+0

@ Bernard Что значит? У меня есть еще одна служба, которая использует SSL, но я не эксперт WCF (это второй раз, когда я ее использую). – Francesco

+1

Вот что я имел в виду; то есть, работали ли вы с другим сервисом WCF с поддержкой SSL. Обеспечение этой услуги «маршрутизации» должно работать одинаково. – Bernard

ответ

4

Хорошо ... Я решил и вторую проблему.

В моем привязке к маршрутизатору не следует указывать тег безопасности, иначе он обрабатывает конверт. Это моя рабочая конфигурация

<?xml version="1.0"?> 
<configuration> 



    <system.serviceModel> 

     <bindings> 
      <!-- Must use custom binding: silverlight only support basicHttpBinding that is not 
        SOAP 1.2. So.. I create a custom binding--> 
      <customBinding> 
       <!-- Security Off version--> 
       <binding name="customBindingNotSecure"> 
        <textMessageEncoding messageVersion="Soap12WSAddressing10"/> 
        <httpTransport /> 
       </binding> 

       <!-- Security On --> 
       <binding name="customBindingSecure"> 
        <textMessageEncoding messageVersion="Soap12WSAddressing10"> 
         <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
       maxArrayLength="2147483647" maxBytesPerRead="2147483647" 
       maxNameTableCharCount="2147483647" /> 
        </textMessageEncoding> 
        <httpsTransport maxBufferPoolSize="2000000" maxBufferSize="2000000" maxReceivedMessageSize="2000000" /> 
       </binding> 

       <binding name="platoneBinding"> 
        <textMessageEncoding messageVersion="Soap12WSAddressing10" />     
        <httpsTransport maxReceivedMessageSize="1000000000" maxBufferPoolSize="1000000000" maxBufferSize="1000000000" /> 
       </binding> 

      </customBinding> 


     </bindings> 

     <services> 

      <service behaviorConfiguration="routingService" name="System.ServiceModel.Routing.RoutingService"> 
       <endpoint address="" 
        binding="customBinding" 
        name="reqReplyEndpoint" 
        contract="System.ServiceModel.Routing.IRequestReplyRouter" bindingConfiguration="customBindingSecure"/> 

       <endpoint address="" 
        binding="customBinding" 
        name="reqReplyEndpointHttp" 
        contract="System.ServiceModel.Routing.IRequestReplyRouter" 
     bindingConfiguration="customBindingNotSecure"/> 

      </service> 


     </services> 
     <behaviors> 

      <serviceBehaviors> 
       <behavior name="routingService"> 
        <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> 
        <serviceDebug includeExceptionDetailInFaults="true" /> 
        <routing routeOnHeadersOnly="true" filterTableName="routingTable1" /> 
       </behavior> 

       <behavior name=""> 
        <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> 
        <serviceDebug includeExceptionDetailInFaults="true" /> 
       </behavior> 
      </serviceBehaviors> 
     </behaviors> 

     <routing> 
      <filters> 
       <filter name="MatchAllFilter1" filterType="MatchAll" /> 
      </filters> 
      <filterTables> 
       <filterTable name="routingTable1"> 
        <add filterName="MatchAllFilter1" endpointName="PlatoneWSService" /> 
       </filterTable> 
      </filterTables> 

     </routing> 

     <client> 
      <!-- https://10.0.2.243:9006/Persistence --> 
      <endpoint address="https://10.0.2.243:9006/Persistence" 
      binding="customBinding" bindingConfiguration="platoneBinding" 
      contract="*" name="PlatoneWSService"> 

      </endpoint> 
     </client> 


     <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    <system.webServer> 
     <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 


    <system.net> 
     <settings> 
      <servicePointManager checkCertificateName="false" checkCertificateRevocationList="false"/> 
     </settings> 
    </system.net> 
</configuration> 

Размеры буфера и сообщения должны быть «испытания» (то есть .. Я выбрал большое число, чтобы сделать это работает ...)