通过SSL配置REST WCF服务

时间:2013-04-03 15:13:27

标签: wcf rest ssl https

我正在构建一个WCF Restful Web服务,目前,我正在通过http传输数据。现在,我想通过https安全地传输数据。我应该在配置文件中更改什么才能启用此功能?这是我当前的配置文件:

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

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="MyService.DBService" behaviorConfiguration="ServiceBehaviour">
        <endpoint address ="" binding="webHttpBinding" contract="MyService.IDBService" behaviorConfiguration="web">
        </endpoint>
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehaviour">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

1 个答案:

答案 0 :(得分:0)

您必须通过定义自定义来配置传输层安全性,并使用bindingConfiguration在端点中引用它。检查this有关配置安全性的信息。在此之后,在IIS中配置SSL证书即可完成此操作。您可以参考this以了解如何使用IIS配置SSL证书。

相关问题