这不是一个问题,但需要澄清。这是代码。所有这些代码正在发送发送cer文件到httpwebrequest中的服务器,该文件放置在本地驱动器上。我的问题是,如果多个用户一次尝试访问应用程序会发生什么情况。我的意思是一次读5-10个请求。它会打破说cer文件被其他线程锁定读取/或不会因为它只是只读而破坏?多个用户同时访问证书文件
//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);
这是一个非常大胆的陈述。我只是声称以共享模式打开的文件也可以由请求共享模式的其他进程打开。 http://msdn.microsoft.com/en-us/library/system.io.fileshare.aspx – 2009-07-22 07:06:12
@Remus Rusanu:我同意;另外一点是File.OpenRead默认为Read-shared模式。 – Stobor 2009-07-23 00:41:41