WCF SSL配置错误可能错误、WCF、SSL

2023-09-03 22:59:25 作者:东京衔尾绽放的薰衣草

试图让通过SSL的HelloWorld的工作。阅读这些文档:

Trying to get HelloWorld working via SSL. Read all these docs:

X509FindType

如何:使用的wsHttpBinding使用Windows身份验证和运输安全的WCF从Windows窗体调用

如何配置的端口,SSL证书

如何为使用创建临时证书在发展

Windows通讯基础(WCF)截屏

我所知道的是,证书似乎是正确创建和部署(两个证书,实际上)。不过,我想什么是错我的web.config(对不起,不能更具体的在这一点)。这就像没有服务器监听443或客户期望的的 HTTP 的而不是 HTTPS 的。可有人请点我到相应的资源和/或告诉我在做什么错了?

All I know is that the certificate seems to be created and deployed correctly (both certificates, actually). Still, I guess something is wrong with my web.config (sorry, can't be more specific at this point). It's like there is no server listening on 443 or client expects an http instead of https. Can someone please point me to the appropriate resource and/or tell what am I doing wrong?

在Web.config是在这里:

The web.config is here:

<?xml version="1.0" encoding="utf-8" ?>

<configuration>
  <appSettings>
    <add key="HTTPBaseAddress" value=""/>
  </appSettings>
  <system.serviceModel>
    <services>
      <service behaviorConfiguration="MyServiceTypeBehaviors" name="MyWCFServices.HelloWorldService">
        <clear />
        <endpoint address="mex" binding="mexHttpBinding" name="mexEndpoint" contract="IMetadataExchange" listenUriMode="Explicit">
          <identity>
            <dns value="localhost" />
            <certificateReference storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectDistinguishedName" />
          </identity>
        </endpoint>
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="" name="SSLendpoint" contract="MyWCFServices.IHelloWorldService">
          <identity>
            <dns value="localhost" />
            <certificateReference x509FindType="FindByThumbprint" findValue="‎82a39faaeb18bf9585b334ca83264add3d5b26ee" />
          </identity>
        </endpoint>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyServiceTypeBehaviors" >
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

客户端的app.config是在这里:

The client-side app.config is here:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
        <bindings>
            <wsHttpBinding>
                <binding name="NoSecurity">
                    <security mode="None" />
                </binding>
                <binding name="SSLsecurity">
                    <security mode="Transport">
                        <transport clientCredentialType="None" />
                        <message clientCredentialType="Certificate" /
                    </security>
                </binding>
            </wsHttpBinding>
        </bindings>
        <client>
            <endpoint address="https://localhost:443/HelloWorldSSL/HelloWorldService.svc"
                binding="wsHttpBinding" bindingConfiguration="" contract="IHelloWorldService"
                name="wsHttpBinding_IHelloWorldService" />
        </client>
    </system.serviceModel>
</configuration>

如果任何额外的信息/截图是必需的 - 我会乐意为它(像往常一样)。希望这是一个回答的问题:)

If any additional info/screenshot is required - I'll happily provide it (as usual). Hope this is an answerable question :)

推荐答案

您的配置不正确。你是不是definining自定义绑定配置在您的端点所以HTTPS不要使用。使用这一个服务器:

Your configuration is not correct. You are not definining custom binding configuration in your endpoint so HTTPS is not used. Use this one for the server:

<bindings>
  <wsHttpBinding>
    <binding name="SSLSecurity">
      <security mode="Transport">
        <transport clientCredentialType="None" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<behaviors> 
  <serviceBehaviors> 
    <behavior name="MyServiceTypeBehaviors" > 
      <serviceMetadata httpGetEnabled="true" /> 
    </behavior> 
  </serviceBehaviors> 
</behaviors> 
<services> 
  <service behaviorConfiguration="MyServiceTypeBehaviors" 
    name="MyWCFServices.HelloWorldService"> 
    <endpoint address="mex" binding="mexHttpBinding" name="mexEndpoint" 
       contract="IMetadataExchange" listenUriMode="Explicit" /> 
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="SSLSecurity" 
       name="SSLendpoint" contract="MyWCFServices.IHelloWorldService" /> 
  </service> 
</services> 

有关客户端的使用:

<bindings>   
  <wsHttpBinding>     
    <binding name="SSLSecurity">   
      <security mode="Transport">   
        <transport clientCredentialType="None" />   
      </security>   
    </binding>   
  </wsHttpBinding>   
</bindings>   
<client>   
  <endpoint address="https://localhost:443/HelloWorldSSL/HelloWorldService.svc"    
     binding="wsHttpBinding" bindingConfiguration="SSLSecurity"   
     contract="IHelloWorldService" name="wsHttpBinding_IHelloWorldService" />   
</client>