簡體   English   中英

多個用戶一次訪問證書文件

[英]Multiple users accessing certificate file at a time

這不是一個問題,但需要澄清。 這是代碼。 這些代碼所要做的就是將cer文件發送到位於本地驅動器上的httpwebrequest中的服務器。 我的問題是,如果多個用戶同時嘗試訪問該應用程序,將會發生什么。 我的意思是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);

讀取操作不會在Windows中鎖定文件。

為什么不從用戶存儲而不是從文件發送證書,並消除這種擔憂,如如何使用HttpWebRequest發送客戶端證書中描述的第二種方法中所述。 無論如何,您都需要將私鑰加載到密鑰存儲中,所以我真的看不到使用.cer文件中的證書的任何意義。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM