How to clear the client-side .Net SSL session cach

2019-04-24 08:43发布

I am writing a little test tool, which uses HttpWebRequest to load test a server. I want for each time I try to call HttpWebRequest.GetResponse() for it establish a fresh SSL session instead of using the one in the cache. Note: I am supplying a client certificate, and using Mutual Authentication for the SSL Session.

Is there a way to clear the SSL Session cache referred to in http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.clientcertificates.aspx ?

2条回答
够拽才男人
2楼-- · 2019-04-24 08:56

I think you're looking for the HttpRequestCacheLevel Enumeration value NoCacheNoStore

http://msdn.microsoft.com/en-us/library/system.net.cache.httprequestcachelevel.aspx

You can then overwrite the HttpRequestCachePolicy

http://msdn.microsoft.com/en-us/library/system.net.webrequest.cachepolicy.aspx

查看更多
别忘想泡老子
3楼-- · 2019-04-24 09:18

The ServicePoint class has an internal method called ReleaseAllConnectionGroups that sets KeepAlive = false on all the connections then releases them. This answer includes all the reflection needed, but setting KeepAlive = false on every HttpWebRequest will keep the client-side .Net SSL session cache clear.

SslEmptyCache may be required to clear caching of SSL-SessionID and/or tickets done by SCHANNEL at the native-code level.

查看更多
登录 后发表回答