2010-08-30 77 views
2

试图获得的HelloWorld通过SSL工作。阅读所有这些文档:WCF SSL配置错误也许

  1. X509FindType

  2. How to: Use wsHttpBinding with Windows Authentication and Transport Security in WCF Calling from Windows Forms

  3. How to: Configure a Port with an SSL Certificate

  4. How to: Create Temporary Certificates for Use During Development

  5. Windows Communication Foundation (WCF) Screencasts

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

的Web.config是在这里:

<?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是在这里:

<?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> 

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

回答

3

你的配置不正确。您没有在端点中定义自定义绑定配置,因此不使用HTTPS。使用这一个服务器:

<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> 
+0

谢谢你 - 这解决了一些probs(有一些自定义)。但是,现在收到另一个错误:根据验证过程,远程证书无效。但在此,在接下来我的stackoverflow问题:) – BreakPhreak 2010-08-31 12:43:30