How do i get an elevation certificate
How do I get the X509Certificate sent from the client in web service?
Apparently I was asking the wrong question in my earlier post. I have a web service secured with a X.509 certificate, running as a secure web site (https://. ). I want to use the client's machine certificate (also X.509) issued by the company's root CA to verify to the server that the client machine is authorized to use the service. In order to do this, I need to inspect the certificate and look for some identifying feature and match that to a value stored in a database (maybe the Thumbprint?).
Here is the code I use to get the certificate from the local certificate store (lifted straight from http://msdn.microsoft.com/en-us/magazine/cc163454.aspx ):
Then, I attach the certificate to the outbound stream thusly:
My question is this -- how do I "get" the certificate in the
web service code? Most sample code snippets I have come across that cover how to do custom validation have a GetCertificate() call in there, apparently assuming that part is so easy everyone should know how to do it?
My main class inherits from WebService, so I can use Context.Request.ClientCertificate to get a certificate, but that's an HttpClientCertificate, not an X509Certificate2. HttpContext gives me the same result. Other approaches all use web configuration code to call pre-defined verification code, with no clue as to how to call a custom C# method to do the verification.
I'm sure this is another "stupid question" that somebody will come back and say "look, just do this and it works," but that's OK. I have spent numerous hours trying to get this to work, and my pride is almost nonexistent at this point. Can somebody show me the error of my ways?Source: stackoverflow.com