public PerfTest(TOptions options) { Options = options; ParallelIndex = Interlocked.Increment(ref _globalParallelIndex) - 1; if (Options.Insecure) { var transport = (new PerfClientOptions()).Transport; // Disable SSL validation if (transport is HttpClientTransport) { _insecureTransport = new HttpClientTransport(new HttpClient(new HttpClientHandler() { ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true })); } else { // Assume _transport is HttpWebRequestTransport (currently internal class) ServicePointManager.ServerCertificateValidationCallback = (message, cert, chain, errors) => true; _insecureTransport = transport; } } if (Options.TestProxies != null && Options.TestProxies.Any()) { if (Options.Insecure) { _recordPlaybackHttpClient = new HttpClient(new HttpClientHandler() { ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true }); } else { _recordPlaybackHttpClient = new HttpClient(); } _testProxy = Options.TestProxies.ElementAt(ParallelIndex % Options.TestProxies.Count()); _testProxyPolicy = new TestProxyPolicy(_testProxy); } }
public PerfTest(TOptions options) { Options = options; if (Options.Insecure) { var transport = (new PerfClientOptions()).Transport; // Disable SSL validation if (transport is HttpClientTransport) { _insecureTransport = new HttpClientTransport(new HttpClient(new HttpClientHandler() { ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true })); } else { // Assume _transport is HttpWebRequestTransport (currently internal class) ServicePointManager.ServerCertificateValidationCallback = (message, cert, chain, errors) => true; _insecureTransport = transport; } } if (Options.TestProxy != null) { if (Options.Insecure) { _recordPlaybackHttpClient = new HttpClient(new HttpClientHandler() { ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true }); } else { _recordPlaybackHttpClient = new HttpClient(); } _testProxyPolicy = new TestProxyPolicy(Options.TestProxy); } }