具有自定义绑定的WCF REST服务的SSL配置

时间:2016-01-13 08:14:51

标签: web-services wcf rest ssl custom-binding

我有一个WCF REST服务,它必须接受来自客户端的原始输入流。为了接收原始流,我在web.config文件中使用自定义绑定。如果我将它设置为通过标准HTTP连接,该服务正常工作。但是,我很难通过HTTPS工作。

消息级安全性不支持手动寻址。配置绑定('CustomBinding','http://tempuri.org/')以使用传输安全性或不进行手动寻址。

以下是我用于HTTP的配置:

<service behaviorConfiguration="LocalBehavior" name="RestService.CreditService">
     <endpoint address="" behaviorConfiguration="web" binding="customBinding" bindingConfiguration="RawReceiveCapable" contract="RestService.ICreditService" />
</service>

<behavior name="LocalBehavior">
     <serviceMetadata httpGetEnabled="true" />
     <serviceDebug includeExceptionDetailInFaults="true" />
</behavior>

<endpointBehaviors>
    <behavior name="web">
      <webHttp />
    </behavior>
</endpointBehaviors>

<binding name="RawReceiveCapable">
    <webMessageEncoding webContentTypeMapperType="RestService.Data.RawContentTypeMapper, RestService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
    <httpTransport manualAddressing="true" maxReceivedMessageSize="524288000"
           transferMode="Streamed" />
</binding>

以下是我用于HTTPS的配置:

<service behaviorConfiguration="SecureBehavior" name="RestService.CreditService">
        <endpoint address="basic" behaviorConfiguration="web" binding="customBinding" bindingConfiguration="RawReceiveCapable" name="httpsEndpoint" contract="RestService.ICreditService" />
        <host>
          <baseAddresses>
            <add baseAddress="http://sitcreditserviceszalecorp.cloudapp.net:3389/CreditService.svc" />
            <add baseAddress="https://sitcreditserviceszalecorp.cloudapp.net:443/CreditService.svc" />
          </baseAddresses>
        </host>
</service>

<behavior name="SecureBehavior">
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
          <serviceDebug httpHelpPageEnabled="false" httpsHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
</behavior>

<binding name="RawReceiveCapable">
          <webMessageEncoding webContentTypeMapperType="RestService.Data.RawContentTypeMapper, RestService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
          <security authenticationMode="CertificateOverTransport"
                  requireSecurityContextCancellation ="true">
          </security>
          <httpsTransport manualAddressing="true" maxReceivedMessageSize="524288000" transferMode="Streamed" authenticationScheme="Anonymous" requireClientCertificate="false" />
</binding>

有谁可以指出我做错了什么?感谢。

1 个答案:

答案 0 :(得分:-1)

我遇到了同样的问题,直到我发现一篇建议删除安全元素的文章。这对我有用。