【问题标题】:Error when configure HTTPS in WCF Service在 WCF 服务中配置 HTTPS 时出错
【发布时间】:2015-04-09 18:33:37
【问题描述】:

我在 VS 2010 .NET 4.0 中有一个 Wcf 服务。

IIS 站点是虚拟目录。

我尝试配置它并使用 https 访问它

https://pruebaslba.xxxx.net/ServicioPyS/Service.svc?wsdl

但我得到错误

Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http].

Could not find a base address that matches scheme https for the endpoint with binding BasicHttpBinding. Registered base address schemes are [http].

谷歌,我看到了几个关于配置的替代方案:serviceMetadata、绑定、baseAddresses、..

我尝试了不同的配置,但我得到了同样的错误:

服务元数据

<serviceMetadata httpGetEnabled="false or true" httpsGetEnabled="true" />

绑定

我用&lt;security mode="Transport"&gt;

 <bindings>

      <basicHttpBinding>
        <binding name="SecureTransportOnly">
          <security mode="Transport">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
          </security>
        </binding>

        <binding name="NoSecure">
          <security mode="None"><transport clientCredentialType="None"/></security>
        </binding>

      </basicHttpBinding>

      <wsHttpBinding>
        <binding name="SecureTransportOnly">
          <security mode="Transport">
              <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
          </security>
        </binding>

      </wsHttpBinding>
    </bindings>

端点

 <endpoint
            address=""
            binding="basicHttpBinding"
            bindingConfiguration="SecureTransportOnly"
            name="xxxActualServiceEndPoint"
            bindingNamespace="https://pruebaslba.xxxx.net/ServicioPyS"
            contract="IxxxActualService">

墨西哥

<endpoint address="mex" binding="mexHttpBinding o mexHttpsBinding" contract="IMetadataExchange"/>

我也试过了:

  <!--<host>
          <baseAddresses>
            <add  baseAddress="https://pruebaslba.xxxx.net o https://pruebaslba.xxxx.net/ServicioPyS"/>
          </baseAddresses>
        </host>-->

          <!--<identity>
            <dns value="localhost" />
          </identity>-->

我想,我尝试了几乎在论坛中找到的配置。我不知道解决方案。

更新 我得到了更多关于它的信息。 该网站位于 2 个服务器中(PreProduction 环境):preiis01 和 preiis02SSL 未启用。

我可以访问http://preiis01/ServicioPyS/Service.svc?wsdl http一切正常。

https://pruebaslba.xxxx.net/ServicioPyS/Service.svc?wsdl 是关于 NLB 的公共 url(负载平衡,我认为是 F5)。在 NLB 中,配置了 SSL。我不知道更多信息,只有IT部门有所有信息。

问题在于 WSDL

http://preiis01/ServicioPyS/Service.svc?wsdl

<wsdl:service name="ActualService">

<wsdl:port name="ActualServiceEndPoint"binding="i0:ActualServiceEndPoint">

<soap:addresslocation="http://preiis01/ServicioPyS/Service.svc/Service.svc" />

</wsdl:port>

</wsdl:service>

NLB 中的 url WSDL 有 soap:address location 部分的问题,并且没有正确生成(设置 http,而不是 https)

https://pruebaslba.xxxx.net/ServicioPyS/Service.svc?wsdl

<wsdl:service name="ActualService">

<wsdl:port name="ActualServiceEndPoint"binding="i0:ActualServiceEndPoint">

<soap:addresslocation="http://pruebaslba.xxxx.net/ServicioPyS/Service.svc/Service.svc" />

</wsdl:port>

</wsdl:service>

快速解决方案是手动修改 WSDL(单个文件)并在 soap:addresslocation 部分中设置 https,在新 url https://pruebaslba.xxxx.net/ServicioPyS/WSDL/ServiceWsdlModificado.Single.wsdl

https://pruebaslba.xxxx.net/ServicioPyS/WSDL/ServiceWsdlModificado.Single.wsdl

<wsdl:service name="ActualService">

<wsdl:port name="ActualServiceEndPoint"binding="tns:ActualServiceEndPoint">

<soap:addresslocation="https://pruebaslba.xxxx.net/ServicioPyS/Service.svc/Service.svc"/>

</wsdl:port>

    </wsdl:service>

我认为,还有另一种具有良好实践的良好解决方案。我不知道。

IIS 中的网站没有启用 SSL,而 NLB 有 SSL。

可能是“SSL pass-through”,我不知道

http://blog.tonysneed.com/2012/06/18/building-scalable-and-secure-wcf-services/

有什么建议吗?

【问题讨论】:

  • 您是否在 IIS 中为您的网站添加了 https 绑定?
  • @Thuan SSL 未在网站 IIS 中启用。仅在 NLB F5 中。也许有用的 SSL 直通,我不知道。站点绑定是 *http 主机名:pruebaslba.xxxx.net 和端口 80 是关于 NLB(负载平衡,F5)的 url ***

标签: c# wcf https wcf-endpoint


【解决方案1】:

有错误表明您的基地址使用“http”方案,而它需要使用“https”。在 IIS 中托管时,地址是在 IIS 中配置的,而不是在 config 中的 hosts 元素。

这意味着您需要在 IIS 中设置 SSL:http://www.iis.net/learn/manage/configuring-security/how-to-set-up-ssl-on-iis

然后以管理员身份打开 Visual Studio,然后转到项目属性的 Web 选项卡并更改那里的基地址以将 https 与本地 IIS 一起使用。 VS 将使用 https 方案为您创建一个虚拟目录。

【讨论】:

  • https://pruebaslba.xxxx.net/ServicioPyS/Service.svc?wsdl 是关于 NLB(负载平衡,F5)的 url
  • 如果您使用的是负载均衡器,请参阅我关于构建可扩展且安全的 WCF 服务的博文:blog.tonysneed.com/2012/06/18/…
  • 基本上你在这种情况下必须做的是“愚弄” WCF 认为绑定传输是安全的,而实际上并非如此。但这里重要的是 SSL 用于保护到 NLB 的流量,但从 NLB 到 WCF 服务器,您应该使用 ipSec 来保护传输。这将为您提供安全性和可扩展性。
猜你喜欢
  • 1970-01-01
  • 2012-04-30
  • 2020-01-12
  • 2013-10-14
  • 2022-01-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-09
相关资源
最近更新 更多