【问题标题】:The protocol 'https' is not supported不支持“https”协议
【发布时间】:2019-01-04 13:19:18
【问题描述】:

我正在使用托管在 IIS 中的 WCF 服务,但是当我尝试导航到端点时,我收到错误“不支持协议'https'”。它托管在本地运行 Windows 10 的 IIS 10 中。

服务正在使用带有 TransportWithMessageCredential 的 wsHttpBinding。

此错误与 SSL 证书或 IIS 有关吗?

我的本​​地计算机中已经有一个有效的本地主机证书 > 个人证书存储。

到目前为止我所做的尝试

  1. 将 httpsGetUrl 属性设置为 .svc 端点。
  2. 检查的 IIS 设置和默认协议设置为“http”,这意味着 http 和 https 协议均已启用。
  3. 检查应用程序池是否使用 .NET Framework 4.0
  4. 重新启动应用程序池

如果有人可以帮助我,我将不胜感激。

这是当前配置:

    <?xml version="1.0"?>
    <configuration>
    <system.web>
    <compilation debug="true" targetFramework="4.0" />
    </system.web>

    <system.serviceModel>
    <services>
        <service name="XXX.Zoo.WebServices.ZooServices_3_0" 
      behaviorConfiguration="ZooServices_3_0_Behavior">
            <endpoint
                address="https://localhost/Zootest_3_0/ZooServices_3_0.svc"
                binding="wsHttpBinding"
                bindingConfiguration="ZooServices_3_0_Binding"
                contract="XXX.Zoo.WebServices.IZooServices_3_0" />
            <endpoint

          address="https://localhost/Zootest_3_0/ZooServices_3_0.svc/mex"
                binding="mexHttpsBinding"
                contract="IMetadataExchange" />
        </service>
        </services>
       <bindings>
        <wsHttpBinding>
            <binding name="ZooServices_3_0_Binding"
                maxReceivedMessageSize="2147483647"
                maxBufferPoolSize="2147483647" >
                <readerQuotas
                    maxDepth="2147483647"
                    maxStringContentLength="2147483646"
                    maxArrayLength="2147483647"
                    maxBytesPerRead="2147483647"
                    maxNameTableCharCount="2147483647"/>
                <security mode="TransportWithMessageCredential">
                    <transport clientCredentialType="None" 
                     proxyCredentialType="None" realm="" />
                    <message clientCredentialType="Certificate" 
              negotiateServiceCredential="true" algorithmSuite="Default" 
              establishSecurityContext="true" />
                </security>
            </binding>
        </wsHttpBinding>
      </bindings>
        <behaviors>
        <serviceBehaviors>
            <behavior name="ZooServices_3_0_Behavior">
                <serviceMetadata httpsGetEnabled="true" 
           httpsGetUrl="https://localhost/Zootest_3_0/ZooServices_3_0.svc" />
                <serviceDebug includeExceptionDetailInFaults="False" />
                <!--The serviceCredentials behavior defines a service 
                  certificate which is used by the service to authenticate 
              itself to  its clients and to provide message protection. -->
                <serviceCredentials>
                    <serviceCertificate
                        findValue="localhost"
                        storeLocation="LocalMachine"
                        storeName="My"
                        x509FindType="FindBySubjectName" />
                    <clientCertificate>
                        <authentication 
                      certificateValidationMode="ChainTrust"/>
                    </clientCertificate>
                </serviceCredentials>
            </behavior>
                 </serviceBehaviors>
            </behaviors>        
          </system.serviceModel>
       </configuration>

【问题讨论】:

  • 为了启用https协议,您应该在IIS站点绑定模块中启用https协议,并将使用传输层安全模式的https服务端点添加到服务中。
  • 从技术上讲,HTTPS 不是一种协议,而是一种方案。协议是 HTTP 和 TLS。

标签: wcf


【解决方案1】:

通过从配置中删除 httpsGetUrl 属性解决了此特定错误:

httpsGetUrl="https://localhost/Zootest_3_0/ZooServices_3_0.svc

所以最终结果是这样的:

<serviceMetadata httpsGetEnabled="true"/>

【讨论】:

    【解决方案2】:

    如果您想启用 https 协议支持,您应该将使用传输传输模式的 https 端点添加到服务中。然后我们应该在IIS站点绑定模块中设置https协议站点绑定。

    我做了一个demo,希望对你有用。
    服务器端。

       [ServiceContract]
        public interface IService1
        {
            [OperationContract]
            string GetData(int value);     
            }
        public class Service1 : IService1
        {
    
            public string GetData(int value)
            {
                return string.Format("You entered: {0}", value);
            }
        }
    

    Web.config

    <system.serviceModel>
        <services>
          <service name="WcfService1.Service1" behaviorConfiguration="mybehavior">
            <endpoint address="" binding="basicHttpBinding" contract="WcfService1.IService1" bindingConfiguration="https"></endpoint>
            <endpoint address="" binding="basicHttpBinding" contract="WcfService1.IService1" bindingConfiguration="http"></endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
          </service>
        </services>
        <bindings>
          <basicHttpBinding>
            <binding name="https">
              <security mode="TransportWithMessageCredential">
                <transport clientCredentialType="None"></transport>
              </security>
            </binding>
            <binding name="http">
              <security mode="None">
              </security>
            </binding>
          </basicHttpBinding>
        </bindings>
        <behaviors>
          <serviceBehaviors>
            <behavior name="mybehavior">
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
              <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <protocolMapping>
            <add binding="basicHttpsBinding" scheme="https" />
        </protocolMapping>    
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
    

    IIS.

    这里有一些链接,希望对你有用。
    WCF Service not hitting from postman over https
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/d42fc165-052d-476a-9580-1240b3d0293d/specify-endpoint-in-wcf-webconfig?forum=wcf
    如果有什么我可以帮忙的,请随时告诉我。

    【讨论】:

      猜你喜欢
      • 2019-08-16
      • 2019-05-28
      • 2019-08-06
      • 2012-03-24
      • 2017-01-10
      • 1970-01-01
      • 2017-09-14
      • 2020-01-22
      • 2018-05-12
      相关资源
      最近更新 更多