Пример #1
0
        public static EvaluatorResults GetConnectionFailedResults(string errorDescription)
        {
            string errorMessage =
                "We were unable to create a TLS connection with this server. This could be because the server does not support " +
                "TLS or because Mail Check servers have been blocked. We will keep trying to test TLS with this server, " +
                $"so please check back later or get in touch if you think there's a problem.";

            if (!string.IsNullOrWhiteSpace(errorDescription))
            {
                errorMessage += $" Error description \"{errorDescription}\".";
            }

            TlsEvaluatorResult tlsEvaluatorResult = new TlsEvaluatorResult(EvaluatorResult.INCONCLUSIVE, errorMessage);

            return(new EvaluatorResults(tlsEvaluatorResult,
                                        new TlsEvaluatorResult(EvaluatorResult.PASS),
                                        new TlsEvaluatorResult(EvaluatorResult.PASS),
                                        new TlsEvaluatorResult(EvaluatorResult.PASS),
                                        new TlsEvaluatorResult(EvaluatorResult.PASS),
                                        new TlsEvaluatorResult(EvaluatorResult.PASS),
                                        new TlsEvaluatorResult(EvaluatorResult.PASS),
                                        new TlsEvaluatorResult(EvaluatorResult.PASS),
                                        new TlsEvaluatorResult(EvaluatorResult.PASS),
                                        new TlsEvaluatorResult(EvaluatorResult.PASS),
                                        new TlsEvaluatorResult(EvaluatorResult.PASS),
                                        new TlsEvaluatorResult(EvaluatorResult.PASS)));
        }
Пример #2
0
 public EvaluatorResults(TlsEvaluatorResult tls12AvailableWithBestCipherSuiteSelected,
                         TlsEvaluatorResult tls12AvailableWithBestCipherSuiteSelectedFromReverseList,
                         TlsEvaluatorResult tls12AvailableWithSha2HashFunctionSelected,
                         TlsEvaluatorResult tls12AvailableWithWeakCipherSuiteNotSelected,
                         TlsEvaluatorResult tls11AvailableWithBestCipherSuiteSelected,
                         TlsEvaluatorResult tls11AvailableWithWeakCipherSuiteNotSelected,
                         TlsEvaluatorResult tls10AvailableWithBestCipherSuiteSelected,
                         TlsEvaluatorResult tls10AvailableWithWeakCipherSuiteNotSelected,
                         TlsEvaluatorResult ssl3FailsWithBadCipherSuite,
                         TlsEvaluatorResult tlsSecureEllipticCurveSelected,
                         TlsEvaluatorResult tlsSecureDiffieHellmanGroupSelected,
                         TlsEvaluatorResult tlsWeakCipherSuitesRejected)
 {
     Tls12AvailableWithBestCipherSuiteSelected = tls12AvailableWithBestCipherSuiteSelected;
     Tls12AvailableWithBestCipherSuiteSelectedFromReverseList =
         tls12AvailableWithBestCipherSuiteSelectedFromReverseList;
     Tls12AvailableWithSha2HashFunctionSelected   = tls12AvailableWithSha2HashFunctionSelected;
     Tls12AvailableWithWeakCipherSuiteNotSelected = tls12AvailableWithWeakCipherSuiteNotSelected;
     Tls11AvailableWithBestCipherSuiteSelected    = tls11AvailableWithBestCipherSuiteSelected;
     Tls11AvailableWithWeakCipherSuiteNotSelected = tls11AvailableWithWeakCipherSuiteNotSelected;
     Tls10AvailableWithBestCipherSuiteSelected    = tls10AvailableWithBestCipherSuiteSelected;
     Tls10AvailableWithWeakCipherSuiteNotSelected = tls10AvailableWithWeakCipherSuiteNotSelected;
     Ssl3FailsWithBadCipherSuite         = ssl3FailsWithBadCipherSuite;
     TlsSecureEllipticCurveSelected      = tlsSecureEllipticCurveSelected;
     TlsSecureDiffieHellmanGroupSelected = tlsSecureDiffieHellmanGroupSelected;
     TlsWeakCipherSuitesRejected         = tlsWeakCipherSuitesRejected;
 }
        public static EvaluatorResults GetHostNotFoundResults(string hostname)
        {
            TlsEvaluatorResult tlsEvaluatorResult = new TlsEvaluatorResult(EvaluatorResult.FAIL,
                                                                           $"This hostname {hostname} does not exist.");

            return(CreateSingleTlsResult(tlsEvaluatorResult));
        }
 private static EvaluatorResults CreateSingleTlsResult(TlsEvaluatorResult tlsEvaluatorResult) =>
 new EvaluatorResults(tlsEvaluatorResult,
                      new TlsEvaluatorResult(EvaluatorResult.PASS), new TlsEvaluatorResult(EvaluatorResult.PASS),
                      new TlsEvaluatorResult(EvaluatorResult.PASS), new TlsEvaluatorResult(EvaluatorResult.PASS),
                      new TlsEvaluatorResult(EvaluatorResult.PASS), new TlsEvaluatorResult(EvaluatorResult.PASS),
                      new TlsEvaluatorResult(EvaluatorResult.PASS), new TlsEvaluatorResult(EvaluatorResult.PASS),
                      new TlsEvaluatorResult(EvaluatorResult.PASS), new TlsEvaluatorResult(EvaluatorResult.PASS),
                      new TlsEvaluatorResult(EvaluatorResult.PASS));
        public void OtherErrorsShouldResultInInconclusive()
        {
            string errorDescription = "Something went wrong!";
            TlsConnectionResult tlsConnectionResult = new TlsConnectionResult(Error.INTERNAL_ERROR, errorDescription, null);
            ConnectionResults   connectionResults   = TlsTestDataUtil.CreateConnectionResults(TlsTestType.Ssl3FailsWithBadCipherSuite, tlsConnectionResult);
            TlsEvaluatorResult  result = _sut.Test(connectionResults);

            Assert.AreEqual(result.Result, EvaluatorResult.INCONCLUSIVE);
            StringAssert.Contains($"Error description \"{errorDescription}\".", result.Description);
        }
        public void ConnectionRefusedErrorsShouldResultInPassWithoutErrorDescription(Error error, string description)
        {
            TlsConnectionResult tlsConnectionResult = new TlsConnectionResult(error, null, null);
            ConnectionResults   connectionResults   = TlsTestDataUtil.CreateConnectionResults(TlsTestType.Ssl3FailsWithBadCipherSuite, tlsConnectionResult);

            TlsEvaluatorResult result = _sut.Test(connectionResults);

            Assert.AreEqual(result.Result, EvaluatorResult.PASS);
            Assert.That(result.Description, Is.Null);
        }
        public void ExpectFailMessageWhenTls12HasError()
        {
            string errorDescription = "Something went wrong!";

            Dictionary <TlsTestType, TlsConnectionResult> data = new Dictionary <TlsTestType, TlsConnectionResult>
            {
                {
                    TlsTestType.Tls12AvailableWithBestCipherSuiteSelected,
                    new TlsConnectionResult(null, null, null, null, Error.BAD_CERTIFICATE, errorDescription, null)
                },
                {
                    TlsTestType.Tls10AvailableWithBestCipherSuiteSelected,
                    new TlsConnectionResult(null, null, null, null, Error.BAD_CERTIFICATE, errorDescription, null)
                }
            };

            ConnectionResults connectionResults = TlsTestDataUtil.CreateConnectionResults(data);

            TlsEvaluatorResult result = _sut.Test(connectionResults);

            Assert.AreEqual(result.Result, EvaluatorResult.FAIL);
            StringAssert.Contains($"Error description \"{errorDescription}\".", result.Description);
        }