locked
Client certificate comes up null when hosting in IIS Express (in unit test is is not null) RRS feed

  • Question

  • User768014394 posted

    We are building a web application with a WCF service that calls a 3rd party web service that uses certificates.  We had a lot of issues getting that to work but now our unit tests can call the 3rd party service by using a reference to the project where our WCF service resides.

    Now I've created an ASP.NET web application (hosted locally in IIS Express) and added a service reference to our WCF service.  In this case, when our WCF service calls the 3rd party web service, the certificate is coming up null and I get this error:

    Exception Type: System.InvalidOperationException

    Message: The client certificate is not provided. Specify a client certificate in ClientCredentials.

    Here is how everything is laid out:

    VS Unit Test project ==> project reference to our WCF service project ==> calls 3rd party web service (no problems)

    Test web application ==> service reference to our WCF service project ==> calls 3rd party web service (doesn't work - certificate is null).

    I am suspecting this may be a permission issue.  I recall that we had to grant read access for our network user accounts to the private key.  I have always assumed that anything running in IIS Express by default uses the current logged in user's identity, but if that was the case I would think the certificate could be found.  I've tried impersonating myself in the web.config, setting the processModel credentials in the applicationHost.config and granting read access to the private key in MMC, but I guess the problem is I don't know the identity of the process to begin with.

    How do I get around this?  All our unit tests work fine but as soon as one of our websites tries consuming our WCF service application, this is going to be a show stopper.

    Tuesday, May 20, 2014 7:08 PM

Answers

  • User768014394 posted

    Sorry I didn't get a chance to look at what you recommended, but I figured it out after my co-worker looked at it.  We were missing the behaviorConfiguration attribute on the endpoint.  Now it works.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 23, 2014 4:12 PM

All replies

  • User-417640953 posted

    Test web application ==> service reference to our WCF service project ==> calls 3rd party web service (doesn't work - certificate is null).

    Message: The client certificate is not provided. Specify a client certificate in ClientCredentials.

    Hi desertfoxaz,

    Thank you post the issue to asp.net forum.

    Above error message means the "Test web application" didn't provide a certificate however your wcf server side needs it's

    client application provide a validate certificate. Please try to provide the certificate in the "Test web application".

    For how to do that, please follow below article.

    http://www.codeproject.com/Articles/36683/9-simple-steps-to-enable-X-509-certificates-on-WCF

    http://www.codeproject.com/Articles/18601/An-easy-way-to-use-certificates-for-WCF-security

    Thanks.

    Best Regards!

    Friday, May 23, 2014 3:58 AM
  • User768014394 posted

    Sorry I didn't get a chance to look at what you recommended, but I figured it out after my co-worker looked at it.  We were missing the behaviorConfiguration attribute on the endpoint.  Now it works.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 23, 2014 4:12 PM