Added more thread safty to ClearSSLSessions
Now it should be safe to use even if another thread is in the middle of storing a session before we disable it.
Showing
1 changed file
with
2 additions
and
0 deletions
| ... | @@ -75,6 +75,7 @@ namespace LIL_VSTT_Plugins | ... | @@ -75,6 +75,7 @@ namespace LIL_VSTT_Plugins | 
| 75 | System.Reflection.Assembly asm = System.Reflection.Assembly.GetAssembly(typeof(System.Net.Security.SslStream)); | 75 | System.Reflection.Assembly asm = System.Reflection.Assembly.GetAssembly(typeof(System.Net.Security.SslStream)); | 
| 76 | Type t = asm.GetType("System.Net.Security.SslSessionsCache"); | 76 | Type t = asm.GetType("System.Net.Security.SslSessionsCache"); | 
| 77 | System.Reflection.FieldInfo f = t.GetField("s_CachedCreds", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); | 77 | System.Reflection.FieldInfo f = t.GetField("s_CachedCreds", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); | 
| 78 | lock (f.GetValue(null)) | ||
| 78 | f.SetValue(null, new ZeroHashtable()); | 79 | f.SetValue(null, new ZeroHashtable()); | 
| 79 | } | 80 | } | 
| 80 | 81 | ||
| ... | @@ -83,6 +84,7 @@ namespace LIL_VSTT_Plugins | ... | @@ -83,6 +84,7 @@ namespace LIL_VSTT_Plugins | 
| 83 | System.Reflection.Assembly asm = System.Reflection.Assembly.GetAssembly(typeof(System.Net.Security.SslStream)); | 84 | System.Reflection.Assembly asm = System.Reflection.Assembly.GetAssembly(typeof(System.Net.Security.SslStream)); | 
| 84 | Type t = asm.GetType("System.Net.Security.SslSessionsCache"); | 85 | Type t = asm.GetType("System.Net.Security.SslSessionsCache"); | 
| 85 | System.Reflection.FieldInfo f = t.GetField("s_CachedCreds", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); | 86 | System.Reflection.FieldInfo f = t.GetField("s_CachedCreds", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); | 
| 87 | lock (f.GetValue(null)) | ||
| 86 | f.SetValue(null, new System.Collections.Hashtable(32)); | 88 | f.SetValue(null, new System.Collections.Hashtable(32)); | 
| 87 | } | 89 | } | 
| 88 | } | 90 | } | ... | ... | 
- 
Please register or sign in to post a comment