Load Balancer SSL Endpoint客户端上的BasicHttpBinding是http,而服务期望https

时间:2018-06-04 12:22:47

标签: wcf http ssl https binding

所以我有这个wcf服务我无法改变,它使用basicHttpBinding进行通信。当它在内部使用时,它就像一个魅力。问题是我试图向公众公开这项服务,但该服务是在强制HTTPS / SSL的负载均衡器后面。这个basicHttpBinding不起作用,因为url转换并将传输设置为等于传输也不起作用。

目前这是我的客户端绑定:

var basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.None);

basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
basicHttpBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.Certificate;
basicHttpBinding.Security.Message.AlgorithmSuite = SecurityAlgorithmSuite.Default;

不确定是否需要最后的部分,无论如何都会抛出相同的错误。

我创建的代理服务看起来像这样:

  <!-- DOWNLOAD HTTP -->
  <service name="ArchiveServiceValidation" behaviorConfiguration="metadataBehavior">
    <endpoint
      address=""
      contract="ArchiveService.IArchiveService"
      name="ArchiveServiceValidationHTTP"
      binding="basicHttpBinding"
      bindingConfiguration="BasicHttpBinding_IArchiveService_HTTP"/>

    <endpoint
      address="mex"
      binding="basicHttpBinding"
      bindingConfiguration="BasicHttpBinding_IArchiveService_HTTP"
      contract="IMetadataExchange"/>
  </service>

  <!-- DOWNLOAD HTTPS -->
  <service name="ArchiveServiceValidationHTTPS" behaviorConfiguration="metadataBehavior">
    <endpoint
      address=""
      contract="ArchiveService.IArchiveService"
      name="ArchiveServiceValidationHTTPS"
      binding="basicHttpBinding"
      bindingConfiguration="BasicHttpBinding_IArchiveService_HTTPS"/>

    <endpoint
      address="mex"
      binding="basicHttpBinding"
      bindingConfiguration="BasicHttpBinding_IArchiveService_HTTPS"
      contract="IMetadataExchange"/>
  </service>


 <client>
  <endpoint
    address="http://url-that-has-to-be-http-no-matter-what-i-do.com"
    binding="basicHttpBinding"
    bindingConfiguration="BasicHttpBinding_IArchiveService_HTTP"
    contract="ArchiveService.IArchiveService"
    name="DownloadDocumentEndpoint">
    <identity>
      <dns value="localhost" />
    </identity>
  </endpoint>
 </client>

以下是我为HTTP和HTTPS设置的绑定。

  <basicHttpBinding>
    <binding maxBufferPoolSize="5000000" maxReceivedMessageSize="5000000" name="BasicHttpBinding_IArchiveService_HTTPS">
      <security mode="Transport">
        <transport clientCredentialType="None"></transport>
        <message clientCredentialType="Certificate" algorithmSuite="Default"/>
      </security>
      <readerQuotas maxArrayLength="5000000" />
    </binding>
    <binding maxBufferPoolSize="5000000" maxReceivedMessageSize="5000000" name="BasicHttpBinding_IArchiveService_HTTP">
      <readerQuotas maxArrayLength="500000000" />
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None"></transport>
        <message clientCredentialType="Certificate" algorithmSuite="Default"/>
      </security>
    </binding>
  </basicHttpBinding>

我的元数据行为配置:

    <behavior name="metadataBehavior">
      <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true" />
      <useRequestHeadersForMetadataAddress>
        <defaultPorts>
          <add port="80" scheme="http"/>
          <add port="443" scheme="https"/>
        </defaultPorts>
      </useRequestHeadersForMetadataAddress>
    </behavior>

1 个答案:

答案 0 :(得分:0)

var basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);

修复了我的问题,原来是2放在我的客户端,我用的是BasicHttpBinding