Как включить HTTPS в службе WCF

Я разместил свой сервис на IIS.

Размещенная служба применила SSL-сертификат, и при просмотре URL-адреса он отображается с HTTPS.

Но когда я использую этот URL-адрес в клиентском приложении (ВЕБ-приложение ASP.NET), он позволяет добавить https//domain/service.svc, но в конфигурации клиента URL-адрес отображается как http, а не https. при ручном изменении выдает следующую ошибку: The provided URI scheme 'https' is invalid; expected 'http'.

Ниже приведена конфигурация службы WCF (размещенная в IIS):

<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="customBehavior">
      <serviceMetadata httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

<bindings>
  <basicHttpBinding>
    <binding name="basicBindingConfiguration" closeTimeout="00:05:00"
            openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:05:00"
            allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
            messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
            useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
          maxBytesPerRead="4096" maxNameTableCharCount="16384" />

      <security mode="None">

      </security>
    </binding>
  </basicHttpBinding>
</bindings>

<serviceHostingEnvironment  multipleSiteBindingsEnabled="true" minFreeMemoryPercentageToActivateService="0" />
<services>
  <service name="Administrator.OAP.CRMServices.CRMServices"
           behaviorConfiguration="customBehavior">
    <endpoint address=""
              binding="basicHttpBinding"
              bindingConfiguration="basicBindingConfiguration"
              contract="Administrator.OAP.CRMServices.Contracts.ICRMServices" />
  </service>
</services>

can any one please guide me what is the problem or changes require here to consume this service with HTTPS only ?


person dsi    schedule 06.11.2014    source источник


Ответы (1)


Ваша привязка имеет это:

<security mode="None">

Это означает, что ваша служба не ожидает использования какой-либо защиты. HTTPS — это транспортная аутентификация, поэтому вам нужно установить:

<security mode="Transport">

Следующая ссылка содержит полезную информацию о настройке безопасности транспорта в WCF: http://msdn.microsoft.com/en-us/library/ms733043(v=vs.110).aspx

person tomasr    schedule 06.11.2014