这不是一个问题,但需要澄清。下面是代码。所有这些代码所做的就是在httpwebrequest中发送一个cer文件到服务器,该文件放在本地驱动器上。我的问题是,如果多个用户同时尝试访问应用程序,会发生什么情况。我的意思是5-10个请求一次读取相同的cer。当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);发布于 2009-07-22 07:02:19
为什么不像How to send a client certificate by using the HttpWebRequest中描述的第二种方法那样,从用户存储中发送证书,而不是从文件中发送证书并消除这种担忧呢?无论如何,您都需要将私钥加载到密钥库中,所以我真的看不出使用.cer文件中的证书有什么意义。
发布于 2009-07-22 00:45:51
读取不会锁定Windows中的文件...
https://stackoverflow.com/questions/1162500
复制相似问题