C#/ Windows7では、私のアプリケーションが既存のSSL接続を再利用しない方法を教えてください。実際には、HttpWebRequestをhttpsページにリクエストすると、既存のconenctionがある場合、この接続(=同じssl-sessionid)が使用されます。私はいくつかのテストを行い、ウィンドウズ7は2分後にSSL接続を再結集します。しかし、私はそれが既存の接続を再利用することはありません。いつでもSSL接続を再接続する方法=異なるssl-SessionID(windows、c#)
は、私は考えているの多くを試してみました: キープアライブ、ClientCacheTime(regeditと)、ServicePointManager.SetTcpKeepAlive ...
どうもありがとうございました!
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
ServicePointManager.DnsRefreshTimeout = 200;
/* ServicePointManager.SetTcpKeepAlive(false,0,0);
ServicePointManager.DefaultConnectionLimit = 100;
ServicePointManager.MaxServicePointIdleTime = 1;*/
// ServicePointManager.DefaultConnectionLimit = 1;
uri = "https://server.com/test.jsp";
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create(uri);
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)";
request.CookieContainer = cookieJar;
request.ContentType = "text/xml";// content type
request.KeepAlive = false;
request.ProtocolVersion = HttpVersion.Version11;
request.Method = "GET";
request.ConnectionGroupName = "dsd" + i;
// request.ReadWriteTimeout = 2000;
/* request.Timeout = 5000;
request.UseDefaultCredentials = false;
request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
request.ConnectionGroupName = DateTime.Now.Ticks.ToString(); */
// X509Certificate2 cert = new X509Certificate2("C:\\a.crt", "abcd");
X509Certificate2 cert = new X509Certificate2();
request.ClientCertificates.Add(cert);
/* request.PreAuthenticate = false;
request.Pipelined = true;*/
WebResponse rsp = request.GetResponse();
string PageContent = new StreamReader(rsp.GetResponseStream()).ReadToEnd();
textBox1.Text = PageContent;
request.ServicePoint.CloseConnectionGroup("dsd" + i);
request.Abort();
request.ClientCertificates.Clear();
rsp.GetResponseStream().Close();
rsp.Close();
request.Abort();
SslEmptyCache https://msdn.microsoft.com/en-us/library/aa380388.aspx – user423430