Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET WebApi - How do I "allow", but not "require" client certificates?

In IIS, I can "ignore", "allow" and "require" client certificates.

In ASP.NET WebAPI (version 4.0 that just launched a little while back), I seem to have the ability to only "ignore" or "require".

By default, client certificates are ignored... so this statement always yields null:

var cert = actionContext.Request.GetClientCertificate();

But, if I set this flag on my config:

config.ClientCredentialType = HttpClientCredentialType.Certificate;

Then I get the client cert... but, I no longer have the ability to allow anonymous access.

My anonymous client now gets a 403 error: "The remote server returned an error: (403) Forbidden."

Can I do a sort of "allow" like in IIS?

like image 511
Timothy Khouri Avatar asked Sep 06 '12 21:09

Timothy Khouri


1 Answers

This is a known limitation with using X509 Certificate in self host scenario. The actual limitation is from the underlying transport binding in WCF, which does not have the allow option with regards to Client Certificate.

You can, however, allow multiple authentications schemes with other options, such as anonymous and windows. We are working with the WCF team to find out if we can add that support with anonymous and x509 certificate as well.

Hope this clarifies.

like image 100
Hongmei Ge Avatar answered Oct 28 '22 02:10

Hongmei Ge