【问题标题】:How to secure webHttpBinding?如何保护 webHttpBinding?
【发布时间】:2013-10-06 10:47:36
【问题描述】:

在我的 WCF 服务中,我试图通过 SSL 连接使用 JSON 向客户端发送数据。我能够使用wsHttpBindingTransport 的安全模式将OData 数据库源保护到我的客户端。为什么webHttpBinding 不能做同样的事情来使用 SSL?我将如何配置需要使用 JSON 来使用 SSL 连接的端点?

本质上webHttpBindingwsHttpBinding 有什么区别?

<bindings>
  <wsHttpBinding>
    <binding name="TransportSecurity">
      <security mode="Transport">
        <transport clientCredentialType="None" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>

  <endpointBehaviors>
    <behavior name="EndpBehavior">
      <webHttp />
    </behavior>
  </endpointBehaviors>
</behaviors>

<services>
  <service behaviorConfiguration="ServiceBehavior" name="DataService4.DataService">

    <endpoint address="" binding="webHttpBinding" contract="DataService4.IService" bindingConfiguration="TransportSecurity" behaviorConfiguration="EndpBehavior" />

    <endpoint contract="IMetadataExchange" binding="mexHttpsBinding" address="mex" />   
  </service>
</services>

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

【问题讨论】:

    标签: json wcf ssl web-config


    【解决方案1】:

    我认为这篇文章会解决你的问题。 Creating a WCF RESTful Service And Secure It Using HTTPS Over SSL

    【讨论】:

    • 链接已损坏。这就是为什么不应将仅链接答案视为答案的原因。
    • 链接没有损坏,我的浏览器出现问题,显示404 not found页面。无论如何,我认为最好在答案中包含这篇文章的摘要,正如它在 SO 的如何回答页面 Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline. 中所说的那样。谢谢。
    【解决方案2】:

    http://www.allenconway.net/2012/05/creating-wcf-restful-service-and-secure.html 的相关部分是这样的:

    <bindings>
      <webHttpBinding>
        <binding>
          <security mode="Transport" />
        </binding>
      </webHttpBinding>
    </bindings> 
    

    如果需要,还可以删除暴露的元数据。

    详细信息记录在 msdn 中:https://msdn.microsoft.com/en-us/library/bb924478(v=vs.110).aspx

    相关部分是:

    使用 HTTPS 提供传输安全性。该服务需要 配置了 SSL 证书。消息是完全安全的 使用 HTTPS 并且服务由客户端使用 服务的 SSL 证书。客户端认证受控 通过transport of webHttpBinding 的ClientCredentialType 属性。

    【讨论】:

      猜你喜欢
      • 2014-08-12
      • 2015-08-10
      • 1970-01-01
      • 2011-05-23
      • 2015-09-22
      • 2010-12-27
      • 2011-02-07
      • 2012-07-16
      相关资源
      最近更新 更多