4

I have created the WCF REST sevice and hosted as windows service. I took the reference from following post.

http://www.codeproject.com/Tips/1009004/WCF-RESTful-on-Windows-Service-Host

Now i am trying to add certificate based authentication on it.

I added the following section inside config file. note : i followed the following msdn link for adding authetication https://msdn.microsoft.com/en-us/library/ff648360.aspx

<bindings>
  <wsHttpBinding>
    <binding name="wsHttpEndpointBinding">
      <security>
        <message clientCredentialType="Certificate" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

and

 <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <serviceCredentials>
            <serviceCertificate findValue="CN=tempCertServer" />
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>

i installed the windows service and when trying to start it. it throws the error.

enter image description here

I removed the following section

<serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
      <serviceCredentials>
        <serviceCertificate findValue="CN=tempCertServer" />
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>

and error disappear. obviously certification didint work.

What could be the reason? am i doing correctly adding certificate based authentication for rest service hosted as windows service?

Suri
  • 3,287
  • 9
  • 45
  • 75

1 Answers1

1
I got the solution.I made following change 

<serviceDebug includeExceptionDetailInFaults="true" />
        I saw the exception in event view logs. service was not able to find certificate,
hence not started.Again created certificate and it works. 
For creating certificate follow following link closely.

https://msdn.microsoft.com/en-us/library/ff648498.aspx

Suri
  • 3,287
  • 9
  • 45
  • 75