C# 中 REST 端点上的 SSL?

发布于 2024-12-08 04:20:39 字数 2355 浏览 0 评论 0原文

我的 SOAP 端点使用 SSL。

但是,一旦我启用 REST 端点,它就会出现问题:

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

我的 app.config:

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="IIncreasedBufferSize" maxBufferSize="1024000"
          maxReceivedMessageSize="1024000">
          <readerQuotas maxArrayLength="1024000" />

          <security mode ="Transport">
            <transport clientCredentialType= "None" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="WCFBehaviourSSL"
        name="IWCF.IService">
        <endpoint name="soap" address="soap" binding="basicHttpBinding" bindingConfiguration="IIncreasedBufferSize"
          contract="IWCF.IServices">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint name="rest"
                  address="rest"
                  binding="webHttpBinding"
                  contract="IWCF.IServices"
                  behaviorConfiguration="REST" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary2/Service1/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="REST">
          <webHttp/>
        </behavior>
      </endpointBehaviors>

      <serviceBehaviors>
        <behavior name="WCFBehaviourSSL">
          <serviceMetadata httpGetEnabled="False" httpsGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>

      </serviceBehaviors>
    </behaviors>

  </system.serviceModel>

我发现了这个问题:通过 SSL 的 REST WCF 服务 但请放心,提供的答案都没有用。

我有证书,并且它确实可以使用 SOAP 端点与 SSL 配合使用。 (当休息端点被注释掉时)。

I have SSL working for my SOAP endpoint.

But as soon as I enable my REST endpoint, it throws a fit:

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

My app.config:

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="IIncreasedBufferSize" maxBufferSize="1024000"
          maxReceivedMessageSize="1024000">
          <readerQuotas maxArrayLength="1024000" />

          <security mode ="Transport">
            <transport clientCredentialType= "None" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="WCFBehaviourSSL"
        name="IWCF.IService">
        <endpoint name="soap" address="soap" binding="basicHttpBinding" bindingConfiguration="IIncreasedBufferSize"
          contract="IWCF.IServices">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint name="rest"
                  address="rest"
                  binding="webHttpBinding"
                  contract="IWCF.IServices"
                  behaviorConfiguration="REST" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary2/Service1/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="REST">
          <webHttp/>
        </behavior>
      </endpointBehaviors>

      <serviceBehaviors>
        <behavior name="WCFBehaviourSSL">
          <serviceMetadata httpGetEnabled="False" httpsGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>

      </serviceBehaviors>
    </behaviors>

  </system.serviceModel>

I found this question: REST WCF Service Over SSL
But rest assured, None of the answers provided are of use.

I have certificates, and it does work with SSL using the SOAP end point. (when rest endpoint is commented out).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

潇烟暮雨 2024-12-15 04:20:39

我缺少一个使用 Transport security: 的 WebHTTPBinding

  <webHttpBinding>
    <binding name ="REST SSL">
      <security mode ="Transport">
        <transport clientCredentialType= "None" />
      </security>
    </binding>                
  </webHttpBinding>

。 。 。

    <endpoint name="rest"
              address="rest"
              binding="webHttpBinding"
              contract="IWCF.IServices"
              behaviorConfiguration="REST" 
              bindingConfiguration="REST SSL"/> 

I was missing a WebHTTPBinding, that uses Transport security:

  <webHttpBinding>
    <binding name ="REST SSL">
      <security mode ="Transport">
        <transport clientCredentialType= "None" />
      </security>
    </binding>                
  </webHttpBinding>

. . .

    <endpoint name="rest"
              address="rest"
              binding="webHttpBinding"
              contract="IWCF.IServices"
              behaviorConfiguration="REST" 
              bindingConfiguration="REST SSL"/> 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文