コード例 #1
0
        public async Task <List <TlsTestResult> > Test(string host)
        {
            List <TlsTestResult> testResults = new List <TlsTestResult>();
            var sw = new Stopwatch();

            _log.LogDebug($"Beginning test run of {_tests.Count} tests for {host ?? "null"}");

            foreach (ITlsTest test in _tests)
            {
                sw.Restart();
                _log.LogDebug($"Running test {test.Id} - {test.Name} for {host ?? "null"}");

                ITlsClient tlsClient = _tlsClientFactory.Create();

                try
                {
                    BouncyCastleTlsTestResult result = await tlsClient.Connect(host, Port, test.Version, test.CipherSuites);

                    _log.LogDebug($"Result of test {test.Id} - {test.Name} for {host ?? "null"}:{ Environment.NewLine}{JsonConvert.SerializeObject(result, JsonSerializerSettings)}");

                    testResults.Add(new TlsTestResult(test, result));
                }
                finally
                {
                    _log.LogDebug($"TLS test {test.Id} - {test.Name} for host {host ?? "null"} completed in {sw.ElapsedMilliseconds}ms");
                    tlsClient.Disconnect();
                }
            }

            return(testResults);
        }
コード例 #2
0
 public TlsSecurityTester(IEnumerable <ITlsTest> tests,
                          ITlsClient client,
                          ILogger log)
 {
     _tests  = tests.OrderBy(_ => _.Id).ToList();
     _client = client;
     _log    = log;
 }