1

I am trying to create client and service applications with Message security with Certificate. But I have some errors all the time and can't make it work. Could somebody suggest what is wrong with my configuration files?

This is the service configuration:

  <system.serviceModel>

<services>
  <service name="SecuredCommunication.Service1" behaviorConfiguration="securedBehavior">
    <endpoint address="test" binding="wsHttpBinding" bindingName="test" name="fasds" bindingConfiguration="securedWsBinding" contract="SecuredCommunication.IService1" >
    </endpoint>
  </service>
</services>

<bindings>
  <wsHttpBinding>
    <binding name="securedWsBinding">
      <security mode="Message">
        <message clientCredentialType="Certificate"/>
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

<behaviors>
  <serviceBehaviors>
    <behavior name="securedBehavior">
      <serviceMetadata httpGetBinding="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
      <serviceCredentials>
        <serviceCertificate findValue="wcftest.pvt" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName"/>
        <clientCertificate>
          <authentication certificateValidationMode="PeerTrust"/>
        </clientCertificate>
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>

and this is the test client configuration

  <system.serviceModel>
<behaviors>
  <endpointBehaviors>
    <behavior>
      <clientCredentials>
        <clientCertificate findValue="wcftest.pvt" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName"/>
      </clientCredentials>
    </behavior>
  </endpointBehaviors>
</behaviors>
<bindings>
  <wsHttpBinding>
    <binding>
      <security mode="Message">
        <message clientCredentialType="Certificate"/>
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<client>
  <endpoint address="http://wcftest.pvt/SecuredCommunication/Service1.svc" binding="wsHttpBinding" contract="SecuredCommunication.IService1">
  </endpoint>
</client>

the current exception I have is:

System.ServiceModel.ServiceActivationException: The requested service, 'http://wcftest.pvt/SecuredCommunication/Service1.svc' could not be activated. See the server's diagnostic trace logs for more information.

For me configuration looks ok, I created it using some manuals from MSDN, so I can't understand what is wrong. I installed certificate using makecert.exe tool like this

makecert.exe MakeCert -pe -ss My -sr LocalMachine -a sha1 -sky exchange -n CN=wcftest.pvt

Thanks, Alexander.

Yaplex
  • 2,272
  • 1
  • 20
  • 38
  • Use [WCF tracing](http://msdn.microsoft.com/en-us/library/ms733025.aspx) to get the detailed error. I think you are using IIS hosted service and IIS doesn't have permission to private key in certificate store. – Ladislav Mrnka Sep 21 '11 at 19:37
  • Thanks Ladislav, It gives me right exception do you have any ideas what is it? Configuration binding extension 'system.serviceModel/bindings/true' could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly. – Yaplex Sep 21 '11 at 21:10

1 Answers1

0

In the service configuration, replace

<serviceMetadata httpGetBinding="true"/> 

by

<serviceMetadata httpsGetBinding="true"/> 

This matches the secure channel configuration applied in the bindings.

kroonwijk
  • 8,340
  • 3
  • 31
  • 52