I've seen a lot of questions similar to this, but none that seem to fit my particular case, I'm hoping this is an easy task though. Sorry if it's been asked before.
I want to connect to an external server via an SSL url (https://). I've confirmed that the crafted URL works by browsing to it in IE. While I did this I also exported the certificate as a .cer file. I then tried to follow the instructions in this article: http://support.microsoft.com/kb/895971
I did this:
X509Certificate Cert = X509Certificate.CreateFromCertFile("C:\\mycert.cer");
HttpWebRequest Request = (HttpWebRequest)WebRequest.Create("https://YourServer/sample.asp");
Request.ClientCertificates.Add(Cert);
HttpWebResponse Response = (HttpWebResponse)Request.GetResponse();
However I am getting a 401 - Not Authorized error, same as when I was trying this code without the logic to add the certificate.
Is this the appropriate method for connecting to an external server with SSL? What am I missng?