微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在HTTPS上托管WCF Windows服务

如何解决在HTTPS上托管WCF Windows服务

我正在尝试配置使用Windows服务在https上托管的WCF服务。

该服务可与http一起使用,但似乎不适用于https。

配置文件(适用于http):

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <serviceHostingEnvironment  aspNetCompatibilityEnabled="false" />

    <!-- Set up Custom Behaviors -->
    <behaviors>
      <serviceBehaviors>
        <behavior name="CalculatorServiceBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetUrl="true" />
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <!-- Set up the binding configuration  -->
    <bindings>
      <wsHttpBinding>
       <binding name="HttpsSOAPBinding">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
        <binding name="HttpSOAPBinding">
          <security mode="None" />
        </binding>
      </wsHttpBinding>
    </bindings>

    <services>
      <service name="Microsoft.ServiceModel.Samples.CalculatorService"
               behaviorConfiguration="CalculatorServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://server_name:8080/ServiceModelSamples/service"/>
          </baseAddresses>
        </host>
        <endpoint address=""
                  binding="wsHttpBinding"
                  bindingConfiguration="HttpSOAPBinding"
                  contract="Microsoft.ServiceModel.Samples.ICalculator" />
        <endpoint address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange" />
      </service>
    </services>
    
  </system.serviceModel>
</configuration>

我为https更改了以下设置:

  • 将wsHttpBinding终结点绑定配置更改为HttpsSOAPBinding
  • 将基本地址更改为http s :// server_name:8080 / ServiceModelSamples / service“
  • 将mex终结点绑定更改为mexHttpsBinding

我还将端口8080连接到了ssl证书。

netsh http show sslcert

 IP:port                      : 0.0.0.0:8080
 Certificate Hash             : 12ea34b0e1e46b12346ae04834cf1deaefb52f33
 Application ID               : {cba53ac4-6ecf-4a49-8aq3-z6c61e2ce9a1}
 Certificate Store Name       : (null)
 Verify Client Certificate Revocation : Enabled
 Verify Revocation Using Cached Client Certificate Only : disabled
 Usage Check                  : Enabled
 Revocation Freshness Time    : 0
 URL Retrieval Timeout        : 0
 Ctl Identifier               : (null)
 Ctl Store Name               : (null)
 DS Mapper Usage              : disabled
 Negotiate Client Certificate : disabled

有什么遗漏吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。