I've written a small console application to make a HTTP call to a server using a client certificate. The code I've written reads the .cer file from the specificed location to make the request:
X509Certificate Cert = X509Certificate.CreateFromCertFile("JohnDoe.cer");
HttpWebRequest Request = (HttpWebRequest)
WebRequest.Create("https://10.135.12.166:4434");
Request.ClientCertificates.Add(Cert);
Request.UserAgent = "Client Cert Sample";
Request.Method = "GET";
HttpWebResponse Response = (HttpWebResponse) Request.GetResponse();
However, this code doesn't work unless you have the certificate installed in the personal folder of the current user inside the certificate manager. More specifically, it only works when I have the .pfx certificate installed, not the .cer
As per my understanding, the client cert is only used for authentication and not encryption, right? So,
Why do we need a certificate to be installed? Why can't my program just pick the .cer file up from the location and send it with the request? And,
Again, more specifically, why do we need the .pfx certificate installed? Why doesn't .cer do the job?