Пример #1
0
        public void ValidateSelfSignedAllowedWithNoChain()
        {
            var path        = Path.Combine(Environment.CurrentDirectory, "security", "TestValidationCertificate.pfx");
            var certificate = new X509Certificate2(path, "abc123");

            var isValid = CertificateValidation.CertificateValidationCallBackAllowsSelfSigned(this, certificate, null, SslPolicyErrors.RemoteCertificateChainErrors);

            Assert.IsTrue(isValid, "The certificate is expected to pass validation");
        }
Пример #2
0
        public void ValidateSelfSignedAllowedNoViolation()
        {
            var path        = Path.Combine(Environment.CurrentDirectory, "security", "TestValidationCertificate.pfx");
            var certificate = new X509Certificate2(path, "abc123");
            var chain       = X509Chain.Create();

            chain.ChainPolicy.RevocationMode    = X509RevocationMode.NoCheck;
            chain.ChainPolicy.RevocationFlag    = X509RevocationFlag.EndCertificateOnly;
            chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllFlags;
            chain.Build(certificate);

            var isValid = CertificateValidation.CertificateValidationCallBackAllowsSelfSigned(this, certificate, chain, SslPolicyErrors.None);

            Assert.IsTrue(isValid, "The certificate is expected to pass validation");
        }