SSL Session Cache Disabled plugin
First tested and fully working version.
Showing
1 changed file
with
32 additions
and
16 deletions
... | @@ -24,38 +24,54 @@ namespace LIL_VSTT_Plugins | ... | @@ -24,38 +24,54 @@ namespace LIL_VSTT_Plugins |
24 | /// <summary> | 24 | /// <summary> |
25 | /// LoadTest Context Copy | 25 | /// LoadTest Context Copy |
26 | /// </summary> | 26 | /// </summary> |
27 | [DisplayName("Clear SSL Sessions")] | 27 | [DisplayName("SSL Session Cache Disabled")] |
28 | [Description("(C) Copyright 2018 LIGHTS IN LINE AB\r\nClears all SSL Sessions after each test from the SSLClients. Beta.")] | 28 | [Description("(C) Copyright 2018 LIGHTS IN LINE AB\r\nDisables SSL Session Cache and Reuse of handshakes during this loadtest. Beta.")] |
29 | public class ClearSSLSessions : ILoadTestPlugin | 29 | public class ClearSSLSessions : ILoadTestPlugin |
30 | { | 30 | { |
31 | LoadTest mLoadTest; | ||
32 | public void Initialize(LoadTest loadTest) | 31 | public void Initialize(LoadTest loadTest) |
33 | { | 32 | { |
34 | mLoadTest = loadTest; | 33 | loadTest.LoadTestStarting += new EventHandler(mLoadTest_Starting); |
35 | mLoadTest.TestStarting += new EventHandler<TestStartingEventArgs>(mLoadTest_TestStarting); | 34 | loadTest.LoadTestFinished += new EventHandler(mLoadTest_Finished); |
36 | mLoadTest.TestFinished += new EventHandler<TestFinishedEventArgs>(mLoadTest_TestFinished); | 35 | loadTest.LoadTestAborted += new EventHandler<LoadTestAbortedEventArgs>(mLoadTest_Aborted); |
37 | mLoadTest.TestSelected += new EventHandler<TestSelectedEventArgs>(mLoadTest_TestSelected); | ||
38 | } | 36 | } |
39 | void mLoadTest_TestStarting(object sender, TestStartingEventArgs e) | 37 | |
38 | void mLoadTest_Starting(object sender, EventArgs e) | ||
40 | { | 39 | { |
41 | clearIt(); | 40 | zeroIt(); |
42 | } | 41 | } |
43 | void mLoadTest_TestFinished(object sender, TestFinishedEventArgs e) | 42 | |
43 | void mLoadTest_Finished(object sender, EventArgs e) | ||
44 | { | ||
45 | undoIt(); | ||
46 | } | ||
47 | |||
48 | void mLoadTest_Aborted(object sender, LoadTestAbortedEventArgs e) | ||
44 | { | 49 | { |
45 | clearIt(); | 50 | undoIt(); |
46 | } | 51 | } |
47 | void mLoadTest_TestSelected(object sender, TestSelectedEventArgs e) | 52 | |
53 | void zeroIt() | ||
48 | { | 54 | { |
49 | clearIt(); | 55 | System.Reflection.Assembly asm = System.Reflection.Assembly.GetAssembly(typeof(System.Net.Security.SslStream)); |
56 | Type t = asm.GetType("System.Net.Security.SslSessionsCache"); | ||
57 | System.Reflection.FieldInfo f = t.GetField("s_CachedCreds", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); | ||
58 | f.SetValue(null, new ZeroHashtable()); | ||
50 | } | 59 | } |
51 | 60 | ||
52 | void clearIt() | 61 | void undoIt() |
53 | { | 62 | { |
54 | System.Reflection.Assembly asm = System.Reflection.Assembly.GetAssembly(typeof(System.Net.Security.SslStream)); | 63 | System.Reflection.Assembly asm = System.Reflection.Assembly.GetAssembly(typeof(System.Net.Security.SslStream)); |
55 | Type t = asm.GetType("System.Net.Security.SslSessionsCache"); | 64 | Type t = asm.GetType("System.Net.Security.SslSessionsCache"); |
56 | System.Reflection.FieldInfo f = t.GetField("s_CachedCreds", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); | 65 | System.Reflection.FieldInfo f = t.GetField("s_CachedCreds", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); |
57 | System.Collections.Hashtable h = (System.Collections.Hashtable)f.GetValue(null); | 66 | f.SetValue(null, new System.Collections.Hashtable(32)); |
58 | h.Clear(); | 67 | } |
68 | } | ||
69 | |||
70 | public class ZeroHashtable : System.Collections.Hashtable | ||
71 | { | ||
72 | public override int Count | ||
73 | { | ||
74 | get { if(base.Count % 32 == 0) this.Clear(); return 0; } | ||
59 | } | 75 | } |
60 | } | 76 | } |
61 | 77 | ... | ... |
-
Please register or sign in to post a comment