how to make a HTTPS GET with a client certificate in .net
Posted by Clarity on 25 Feb 2005 at 08:50 pm | Tagged as: Tech
I’ve spent the last hour or so trying to find how to open an SSL encrypted http session using a client certificate. It seems that this should do it:
Kenny Kerr
To use a certificate, the client needs to be issued a certificate by a certificate authority. Since the certificate has an associated private key, it needs to be kept safe. This is handled by a certificate store which you can access using the Cryptography API or though Internet Explorer. Here is an example of using a client certificate:
Uri uri = new Uri(”https://server/application”);
X509Certificate certificate = X509Certificate.CreateFromCertFile(@”C:\client.cer”);
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(uri);
request.ClientCertificates.Add(certificate);
using (WebResponse response = request.GetResponse())
{
// TODO: read response
}