Example #1
0
        public static void CheckCallbackChain(TestContext ctx, ConnectionTestParameters parameters,
                                              X509Certificate certificate, X509Chain chain,
                                              SslPolicyErrors errors)
        {
            if (parameters.ExpectPolicyErrors != null)
            {
                // FIXME: AppleTls reports RemoteCertificateChainErrors instead of RemoteCertificateNameMismatch.
                if (parameters.ExpectPolicyErrors.Value == SslPolicyErrors.RemoteCertificateNameMismatch)
                {
                    ctx.Expect(errors, Is.EqualTo(SslPolicyErrors.RemoteCertificateNameMismatch).Or.EqualTo(SslPolicyErrors.RemoteCertificateChainErrors));
                }
                else
                {
                    ctx.Expect(errors, Is.EqualTo(parameters.ExpectPolicyErrors.Value));
                }
            }

            if (parameters.ExpectChainStatus != null && ctx.Expect(chain, Is.Not.Null, "chain"))
            {
                if (ctx.Expect(chain.ChainStatus, Is.Not.Null, "chain.ChainStatus"))
                {
                    ctx.Expect(chain.ChainStatus.Length, Is.EqualTo(1), "chain.ChainStatus.Length");
                    ctx.Expect(chain.ChainStatus[0].Status, Is.EqualTo(parameters.ExpectChainStatus.Value), "chain.ChainStatus.Status");
                    ctx.LogMessage("STATUS: {0}", chain.ChainStatus[0].Status);
                }
                if (ctx.Expect(chain.ChainElements, Is.Not.Null, "chain.ChainElements"))
                {
                    ctx.Expect(chain.ChainElements.Count, Is.EqualTo(1), "chain.ChainElements.Count");
                }
                ctx.LogMessage("ELEMENTS: {0}", chain.ChainElements[0].ChainElementStatus[0].Status);
            }
        }
        public ConnectionTestRunner(IServer server, IClient client, ConnectionTestProvider provider, ConnectionTestParameters parameters)
            : base(server, client, parameters)
        {
            Provider = provider;

            ConnectionHandler = CreateConnectionHandler();
        }