3

Добрый день!

Спасибо что зашли. Я столкнулся с такой задачей.

Есть сервер, на нем установлены в IIS 4 WCF-сервиса:

Service1 : 1100 (основной)
Service2 : 1101
Service3 : 1102
Service4 : 1103

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

Ошибка при вызове сервиса 2:

System.ServiceModel.Security.SecurityNegotiationException: Could not establish secure channel for SSL/TLS with authority ':1101'. ---> System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.

Я проверил сертификаты - мы заходим на второй сервис с нужным сертификатом. У меня есть подозрения, что ошибка в веб-конфиге.

Подскажите, пожалуйста, как решить эту проблему? Я с сертификатами только начинаю работать.

Ниже находится мой веб-конфиг:

<configuration>
  <connectionStrings>
    <add name="DSN" connectionString="........."/>
  </connectionStrings>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <pages validateRequest="false" />
    <customErrors mode="RemoteOnly"/>
  </system.web>

  <system.serviceModel>

    <client>
      <endpoint address="https://SERVER:1101/PinSetup.svc/SoapBufferedCert"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IPinSetup"
        contract="PinSetupService.IPinSetup" name="BasicHttpBinding_IPinSetup" behaviorConfiguration="clientEndpointCredential"/>
      <endpoint address="https://SERVER:1102/Service.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISmsGate"
        contract="SmsGateServiceReference.ISmsGate" name="BasicHttpBinding_ISmsGate" />
      <endpoint address="https://SERVER:1103/" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_FZCoreModuleContract_2_1"
        contract="SrNotifyService.FZCoreModuleContract_2_1" name="BasicHttpBinding_FZCoreModuleContract_2_1" />
    </client>
    <services>
      <service behaviorConfiguration="CertCoreBehavior" name="PrepaidServiceNS.PrepaidService">
        <endpoint address="SoapBufferedCert" binding="basicHttpBinding" bindingConfiguration="SecurityBinding" contract="PrepaidServiceNS.IPrepaid"/>
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>

        <!--  Сертификаты  -->
        <behavior name="CertCoreBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceThrottling
              maxConcurrentSessions="1000"
              maxConcurrentCalls="1000"
              maxConcurrentInstances="10000" />
          <serviceCredentials>
            <windowsAuthentication allowAnonymousLogons="false" includeWindowsGroups="false"/>
            <clientCertificate>
              <authentication mapClientCertificateToWindowsAccount="true" />              
            </clientCertificate>
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="clientEndpointCredential">
          <clientCredentials>
            <clientCertificate storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectName" findValue="j-TestCertClient" />
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
    </behaviors>

    <bindings>
      <basicHttpBinding>
        <binding name="SecurityBinding">
          <security mode="Transport">
            <transport clientCredentialType="Certificate" />
          </security>
        </binding>
        <binding name="BasicHttpBinding_IPinSetup">
          <security mode="Transport">
            <transport clientCredentialType="Certificate" />
          </security>
        </binding>
        <binding name="BasicHttpBinding_ISmsGate">
          <security mode="Transport" />
        </binding>
        <binding name="BasicHttpBinding_FZCoreModuleContract_2_1">
          <security mode="Transport" />
        </binding>
      </basicHttpBinding>
    </bindings>

  </system.serviceModel>

</configuration>

2 ответа 2

1

Надо обращаться к серверу по тому же имени, которое прописано в сертификате. Для всех остальных сертификат будет невалидным. Если сертификат выдан на smth.comecompany.com, то обращение через localhost или ip-адрес будет неверным.

Ещё надо убедиться, что сертификат привязан к порту. Если сертификат не совсем валидный (для разработки, когда ещё добавляется рутовый сертификат, который тоже сгенерирован), привязка к портам слетает при перезагрузке. Надо перепривязать заново.

2
  • совершенно верное замечание. Спасибо. 18 июн 2015 в 11:55
  • @LeonardBertone, верное - в смысле помогло, или в смысле, что ты уже об этом в курсе?)
    – Qwertiy
    18 июн 2015 в 13:31
0

Могу дать три рекомендации на сей счет:

  1. Всегда обновляться в Service References ссылку на сервис после его апдейта на сервере

  2. проверяйте доступ пользователя, под которым запущен Пул, к физической папке сервиса

  3. проверьте сертификаты и ендпоинты

Мне это помогло.

1
  • P.S. с веб-конфигом все в порядке. 18 июн 2015 в 11:03

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.