【问题标题】:How to get WCF Service Running over SSL?如何让 WCF 服务在 SSL 上运行?
【发布时间】:2011-08-14 07:01:21
【问题描述】:

我在 IIS6 中运行 C# Web 服务并试图让它通过 SSL 工作。在执行 tcpdump 时,它会将初始调用显示为 https,但其他所有调用都显示为 http。我的 SSL 证书是自签名的,并且 https 在我的网络浏览器中运行良好。我正在为客户端使用 PHP SoapClient。

有谁知道这是什么原因造成的?

在 wsdl 中,地址位置设置为 http。这应该是https吗?怎么改?

<wsdl:service name="Service">
<wsdl:port name="BasicHttpBinding_Service" binding="i0:BasicHttpBinding_Service">
<soap:address location="http://example.com/Service.svc"/>
</wsdl:port>
</wsdl:service>

【问题讨论】:

  • 差别很大。以后你应该说哪个。 “.NET C# Web 服务”不明确。

标签: c# wcf web-services ssl https


【解决方案1】:

您必须将您的服务配置为使用 HTTPS:

<bindings>
  <basicHttpBinding>
    <binding name="https">
      <security mode="Transport" />
    </binding>
  </basicHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="metadata">
      <serviceMetadata httpsGetEnabled="true" />  
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service name="..." behaviorConfiguration="metadata">
    <endpoint address="..." contract="..." binding="basicHttpBinding"
              bindingConfiguration="https" />
  </service>
</services>

这将允许仅通过 HTTPS 调用您的服务,因为没有暴露不安全的端点。 WSDL 也只能通过 HTTPS 访问,因为未启用 HTTP GET。

【讨论】:

  • 没有人回答 OP 的另一个问题:在 wsdl 中,地址位置设置为 http。这应该是https吗?我该如何改变它?请告诉我,如果上述对配置文件的更改也将地址位置更改为 https?有必要吗?
  • @WinFXGuy:WSDL 中的地址位置也应该是 HTTPS。如果不是,您还有一些额外的配置问题。
  • 我错过了什么吗?请参考我的问题:stackoverflow.com/questions/13502185/…
猜你喜欢
  • 2017-11-26
  • 2020-12-16
  • 1970-01-01
  • 2012-12-18
  • 2013-05-26
  • 1970-01-01
  • 2017-05-12
  • 1970-01-01
  • 2014-03-31
相关资源
最近更新 更多