如何在WCF服务中启用HTTPS



我已经在IIS上托管了我的服务。

托管服务已应用SSL证书,在浏览URL时,它显示为HTTPS。

但是,当我在客户端应用程序(ASP.NET WEB应用程序)中使用此URL时,它允许添加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>

有人能告诉我,只使用HTTPS使用此服务需要什么问题或更改吗?

您的绑定有以下内容:

<security mode="None">

这意味着您的服务不希望使用任何类型的安全性。HTTPS是传输身份验证,因此您需要设置:

<security mode="Transport">

以下链接包含有关在WCF中设置传输安全性的有用信息:http://msdn.microsoft.com/en-us/library/ms733043(v=vs.110).aspx

最新更新