Exemplo n.º 1
0
        public void _02_TestWithOneRootCertificate()
        {
            X509Certificate2 rootCertificate1 = new X509Certificate2(TestConstants.PATH_CERTIFICATE_PROD_ROOT_OCES2);
            X509Certificate2 rootCertificate2 = new X509Certificate2(TestConstants.PATH_CERTIFICATE_PROD_ROOT_OCES1);

            // Test Oces2 cert
            X509Certificate2 functionCertificate = new X509Certificate2(TestConstants.PATH_CERTIFICATE_DEVICE, TestConstants.PASSWORD_CERTIFICATE_DEVICE);

            X509Certificate2[] rootCertificates            = new X509Certificate2[] { rootCertificate2 };
            MultipleRootX509CertificateValidator validator = new MultipleRootX509CertificateValidator(rootCertificates);

            try
            {
                validator.Validate(functionCertificate);

                Assert.IsFalse(true, "Certificate should not be trusted");
            }
            catch (CertificateRootNotTrustedException exception)
            {
                Console.WriteLine(exception.ToString());
                Assert.IsTrue(true);
            }
            catch (Exception)
            {
                // Not correct type of exception
                Assert.IsFalse(true);
            }
        }
Exemplo n.º 2
0
        public void _01_TestWithOneRootCertificate()
        {
            X509Certificate2 rootCertificate1    = new X509Certificate2(TestConstants.PATH_CERTIFICATE_TEST_ROOT_OCES1);
            X509Certificate2 rootCertificate2    = new X509Certificate2(TestConstants.PATH_CERTIFICATE_TEST_ROOT_OCES2);
            X509Certificate2 functionCertificate = new X509Certificate2(TestConstants.PATH_CERTIFICATE_DEVICE, TestConstants.PASSWORD_CERTIFICATE_DEVICE);

            X509Certificate2[] rootCertificates            = new X509Certificate2[] { rootCertificate1, rootCertificate2 };
            MultipleRootX509CertificateValidator validator = new MultipleRootX509CertificateValidator(rootCertificates);

            validator.Validate(functionCertificate);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Constructor
 /// </summary>
 public CertificateValidatorWithLookup()
 {
     this.logger    = LoggerFactory.Create(this);
     this.validator = new MultipleRootX509CertificateValidator();
 }