Tutorial :Multiple users accessing certificate file at a time


This is kind of not a question, but need a clarification. Here is the code. All this code is doing is sending sending a cer file to server in httpwebrequest which is placed on a local drive. My question is, what happens if multiple users try to access the application at a time. I mean 5-10 requests reading the same cer at a time. will it break saying that the cer file is locked by some other thread to read/or will it not break because it's just read only?

//You must change the path to point to your .cer file location.   X509Certificate Cert = X509Certificate.CreateFromCertFile("C:\\mycert.cer");  // Handle any certificate errors on the certificate from the server.  ServicePointManager.CertificatePolicy = new CertPolicy();  // You must change the URL to point to your Web server.  HttpWebRequest Request = (HttpWebRequest)WebRequest.Create("https://YourServer/sample.asp");  Request.ClientCertificates.Add(Cert);  Request.UserAgent = "Client Cert Sample";  Request.Method = "GET";  HttpWebResponse Response = (HttpWebResponse)Request.GetResponse();  // Print the repsonse headers.  Console.WriteLine("{0}",Response.Headers);  Console.WriteLine();  // Get the certificate data.  StreamReader sr = new StreamReader(Response.GetResponseStream(), Encoding.Default);  int count;  char [] ReadBuf = new char[1024];  do  {      count = sr.Read(ReadBuf, 0, 1024);      if (0 != count)      {          Console.WriteLine(new string(ReadBuf));      }    }while(count > 0);  


Why not send the certificate from the user store instead of file and eliminate the concern, as in the second method described in How to send a client certificate by using the HttpWebRequest. You need to load the private key into the key store anyway, so I really don't see any point in using the certificate from a .cer file.


Reads don't lock files in Windows....

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »