c# - C# 中 REST 端点上的 SSL?

标签 c# rest ssl endpoint

我的 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>

我发现了这个问题:REST WCF Service Over SSL 但请放心,所提供的答案都没有用。

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

最佳答案

我缺少一个使用传输安全的 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"/> 

关于c# - C# 中 REST 端点上的 SSL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7673249/

相关文章:

java - 如何修复 SSLProtocolException : handshake alert: unrecognized_name without disabling SNI

c# - 我可以将动态创建的 c# 表转换为 html 字符串吗?

java - 无法在本地主机上运行 rest api Web 服务

从命令行进行 Rest API 测试

swift - 在 Alamofire PUT 请求中传递一个整数作为参数

security - 相互 SSL - 多少身份验证就足够了?

c# - 已成功与服务器建立连接,但在登录前握手期间发生错误。 (提供商 : SSL Provider, 错误:0

c# - DataTable 表达式无法解释标记 '!'

c# - TFS/VS 错误地将文件标记为有更改?

c# - 关闭 Visual Studio 2013 预处理器灰显 C#?