C# 每个请求都是一次完整的ssl握手,如何重用ssl会话?
.NET Framework 4.x 我有一个带有c#的HTTP客户端,我发现C# 每个请求都是一次完整的ssl握手,如何重用ssl会话?,c#,.net,ssl,https,session-reuse,C#,.net,Ssl,Https,Session Reuse,.NET Framework 4.x 我有一个带有c#的HTTP客户端,我发现HTTPS请求总是完全握手。但是如果使用Postman请求,它将逐个会话重用SSL会话 这些是通过wireshark捕获的数据包: client hello Extension:session_ticket(len=0) sever hello Extension:session_ticket(len=0) New Session Ticket Handshake Protocol:
HTTPS
请求总是完全握手。但是如果使用Postman请求,它将逐个会话重用SSL会话
这些是通过wireshark捕获的数据包:
client hello
Extension:session_ticket(len=0)
sever hello
Extension:session_ticket(len=0)
New Session Ticket
Handshake Protocol: New Session Ticket
Handshake Type: New Session Ticket (4)
Length: 214
TLS Session Ticket
Session Ticket Lifetime Hint: 100800 seconds (1 day, 4 hours)
Session Ticket Length: 208
Session Ticket: 50bb2ffffb6ba4e17cdb6d4c6239f8decd2d590d97b01db4…
每个请求包都与上面相同
如果使用邮递员请求
client hello
Extension:session_ticket(len=208)
有人知道吗
这是我的HTTP客户端
ServicePointManager.ServerCertificateValidationCallback = validationCallback;
if (strUrl.StartsWith("https"))
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;// | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
}
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(strUrl);
httpWebRequest.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.CacheIfAvailable);
httpWebRequest.Method = "POST";
httpWebRequest.ContentType = "application/octet-stream";
httpWebRequest.Timeout = 30000; ///10s
httpWebRequest.ReadWriteTimeout = 30000; ///10s
httpWebRequest.KeepAlive = false;
httpWebRequest.ContentLength = bytes.Length;
httpWebRequest.Headers.Add("CustomKey", ident.ToString());
httpWebRequest.BeginGetRequestStream(new AsyncCallback(WriteCallback), new RequestState(httpWebRequest, bytes));