如何解决每个请求都是完整的ssl握手,如何重用ssl会话?
.NET Framework 4.x
我有一个使用c#的HTTP客户端,我发现HTTPS
请求始终是完整的握手。但是,如果使用Postman进行请求,它将通过session_ticket重用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));
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。