views:

14

answers:

1

hey there

Trying to get HelloWorld working via SSL. Read all those docs: http://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509findtype.aspx http://msdn.microsoft.com/en-us/library/ff648431.aspx http://msdn.microsoft.com/en-us/library/ms733791.aspx http://msdn.microsoft.com/en-us/library/ms733813.aspxhttp://msdn.microsoft.com/en-us/netframework/wcf-screencasts.aspx

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?

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>

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 :)

+1  A: 

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> 

For client use:

<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> 
Ladislav Mrnka
thank you - that solved some probs (with a few customizations). however, now receiving another error: The remote certificate is invalid according to the validation procedure. But on that, in the next my stackoverflow question :)
BreakPhreak