Commit c2cc16a9 c2cc16a93a58fa43a17ae5e3ce1118fc89c05d93 by Christian Gerdes

SSL Session Cache Disabled plugin

First tested and fully working version.
1 parent 1eac38b7
......@@ -24,38 +24,54 @@ namespace LIL_VSTT_Plugins
/// <summary>
/// LoadTest Context Copy
/// </summary>
[DisplayName("Clear SSL Sessions")]
[Description("(C) Copyright 2018 LIGHTS IN LINE AB\r\nClears all SSL Sessions after each test from the SSLClients. Beta.")]
[DisplayName("SSL Session Cache Disabled")]
[Description("(C) Copyright 2018 LIGHTS IN LINE AB\r\nDisables SSL Session Cache and Reuse of handshakes during this loadtest. Beta.")]
public class ClearSSLSessions : ILoadTestPlugin
{
LoadTest mLoadTest;
public void Initialize(LoadTest loadTest)
{
mLoadTest = loadTest;
mLoadTest.TestStarting += new EventHandler<TestStartingEventArgs>(mLoadTest_TestStarting);
mLoadTest.TestFinished += new EventHandler<TestFinishedEventArgs>(mLoadTest_TestFinished);
mLoadTest.TestSelected += new EventHandler<TestSelectedEventArgs>(mLoadTest_TestSelected);
loadTest.LoadTestStarting += new EventHandler(mLoadTest_Starting);
loadTest.LoadTestFinished += new EventHandler(mLoadTest_Finished);
loadTest.LoadTestAborted += new EventHandler<LoadTestAbortedEventArgs>(mLoadTest_Aborted);
}
void mLoadTest_TestStarting(object sender, TestStartingEventArgs e)
void mLoadTest_Starting(object sender, EventArgs e)
{
clearIt();
zeroIt();
}
void mLoadTest_TestFinished(object sender, TestFinishedEventArgs e)
void mLoadTest_Finished(object sender, EventArgs e)
{
undoIt();
}
void mLoadTest_Aborted(object sender, LoadTestAbortedEventArgs e)
{
clearIt();
undoIt();
}
void mLoadTest_TestSelected(object sender, TestSelectedEventArgs e)
void zeroIt()
{
clearIt();
System.Reflection.Assembly asm = System.Reflection.Assembly.GetAssembly(typeof(System.Net.Security.SslStream));
Type t = asm.GetType("System.Net.Security.SslSessionsCache");
System.Reflection.FieldInfo f = t.GetField("s_CachedCreds", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
f.SetValue(null, new ZeroHashtable());
}
void clearIt()
void undoIt()
{
System.Reflection.Assembly asm = System.Reflection.Assembly.GetAssembly(typeof(System.Net.Security.SslStream));
Type t = asm.GetType("System.Net.Security.SslSessionsCache");
System.Reflection.FieldInfo f = t.GetField("s_CachedCreds", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
System.Collections.Hashtable h = (System.Collections.Hashtable)f.GetValue(null);
h.Clear();
f.SetValue(null, new System.Collections.Hashtable(32));
}
}
public class ZeroHashtable : System.Collections.Hashtable
{
public override int Count
{
get { if(base.Count % 32 == 0) this.Clear(); return 0; }
}
}
......