Search code examples
c#wcfclient-certificates

How can I read the Clientcertificate within a WCF service?


I do host a WCF service on a server which requires the clients to authenticate using a x509 certificate. I need to read this certificate inside the service as the data contained is part of the business logic.

The binding I use for the WCF service is webHttpBinding with security set to "Transport" and clientCredentialType="certificate".

In ASP.net I can use the HttpContext.Current, which however is not available in WCF. What can I do to still get the certificate from the user?

Kind regards, Alois


Solution

  • The article on http://blogs.msdn.com/b/wenlong/archive/2006/01/23/516041.aspx provided me with the solution to this problem. WCF allows to run in "ASP.net compatibility mode" which brings back the full HttpContext object.