如何在WCF服务中启用HTTPS [英] How to enable HTTPS in WCF service

查看:190
本文介绍了如何在WCF服务中启用HTTPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在IIS上托管了服务.

I have hosted my service on IIS.

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

Hosted service has applied SSL certificate and on browse of URL, it appears with HTTPS.

但是,当我确实将此URL消费到客户端应用程序(ASP.NET WEB应用程序)中时,它允许添加https//domain/service.svc,但是在客户端配置上,URL显示为http而不是https.然后进行手动更改时,会出现如下错误:The provided URI scheme 'https' is invalid; expected 'http'.

But, when i do consume this URL into client application (ASP.NET WEB Application) then, it allows to add https//domain/service.svc but, on client configuration, it appears the URL as http and not https. when do manual change then, it gives error as follow: The provided URI scheme 'https' is invalid; expected 'http'.

以下是WCF服务配置(托管在IIS上):

Below is the WCF service configuration (hosted on 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来使用此服务吗?

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

推荐答案

您的绑定具有此功能:

<security mode="None">

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

Which means your service is not expecting to use security of any kind. HTTPS is transport authentication, so you need to set:

<security mode="Transport">

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

The following link includes useful information about setting up transport security in WCF: http://msdn.microsoft.com/en-us/library/ms733043(v=vs.110).aspx

这篇关于如何在WCF服务中启用HTTPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆