I am trying to get client certificate in web service.
I add client certificate in proxy object and call web method
Verify
.private void button2_Click(object sender, EventArgs e) { string certPath = "D:\\test.pfx"; cert = new X509Certificate2(certPath,"pass"); Service1 obj = new Service1(); obj.ClientCertificates.Add(cert); textBox2.Text = obj.Verify(); }
Web Method in Web Service:
[WebMethod]
public string Verify()
{
X509Certificate2 cert = new X509Certificate2(Context.Request.ClientCertificate.Certificate);
bool test = cert.Verify();
return test.ToString();
}
In finish with this error:
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Security.Cryptography.CryptographicException: m_safeCertContext is an invalid handle.
I don't know why. I used this sample.
I test web service and client on localhost.