有没有人尝试过在 WCF Web 服务中使用 SSL 自定义绑定(bind)?我已经看到许多关于如何使用 basicHttpBinding 和 wsHttpBinding 执行此操作的示例,但等效项对于 customBinding 总是失败。具体来说,我目前正在使用的(最成功的配置)看起来像这样:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
</serviceHostingEnvironment>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="binaryHttps">
<binaryMessageEncoding />
<httpsTransport />
</binding>
</customBinding>
</bindings>
<services>
<service behaviorConfiguration="MyServiceBehavior" name="MyService">
<host>
<baseAddresses>
<add baseAddress="https://(myserver)/"/>
</baseAddresses>
</host>
<endpoint address=""
binding="customBinding" bindingConfiguration="binaryHttps"
contract="MyService" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
这实际上允许我们从 Web 访问服务,获取它的 WSDL 并在 visual studio 中添加一个服务引用好吧,但是当我们实际尝试在我们的 silverlight-3 应用程序中使用它时,它只是无限期地等待以获得响应并且永远不会超时。实际上,在我的机器上运行一段时间后(内存为 6GB),它最终给我带来了内存不足的问题。奇怪的是,所有这些在开发环境(严格使用 VS 应用程序主机)中(并且仍然)完美地工作,直到我们尝试将它部署到具有真实 SSL 证书的实际服务器时,所有这些问题才出现弹出。
我已经相当详尽地搜索了这个问题的解决方案,但到目前为止还没有找到任何东西并且尝试了几乎所有的东西 - 有没有人以前遇到过这个问题并解决了这个问题?
最佳答案
所以事实证明问题根本不在于我们的 web.config,它与 IIS 7 和 Wildcard SSL 证书有关。
也就是说,IIS 7 不允许您在将 IP 绑定(bind)到 SSL 连接和证书时指定主机名。我猜这是因为它需要一个非通配符 SSL 证书,它可以从中提取显式主机名。我们最终要做的是进入 {WindowsDir}\{System32}\{Inetsrv}\{config} 中的 applicationHost.config 文件,找到包含我们的 Web 服务绑定(bind) IP 地址的条目,并将其显式更改为 (ip ):(主机名)。然后它甚至可以在 IIS 配置 GUI 中正确显示。
完成此操作后,我们将完全关闭所有服务器上除 SSL channel 以外的所有 channel ,一切都运行良好。
谢天谢地,一切都结束了!
https://stackoverflow.com/questions/1129020/