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

后端 未结 2 769
花落未央
花落未央 2021-02-19 18:56

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 se

2条回答
  •  闹比i
    闹比i (楼主)
    2021-02-19 19:42

    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.

提交回复
热议问题