This class contains a cross certificate pair. Cross certificates pairs may contain two cross signed certificates from two CAs. A certificate from the other CA to this CA is contained in the forward certificate, the certificate from this CA to the other CA is contained in the reverse certificate.
        public override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }
            X509CertificatePair x509CertificatePair = obj as X509CertificatePair;

            return(x509CertificatePair != null && object.Equals(this.forward, x509CertificatePair.forward) && object.Equals(this.reverse, x509CertificatePair.reverse));
        }
Exemplo n.º 2
0
        public override bool Equals(
            object obj)
        {
            if (obj == this)
            {
                return(true);
            }

            X509CertificatePair other = obj as X509CertificatePair;

            if (other == null)
            {
                return(false);
            }

            return(Platform.Equals(this.forward, other.forward) &&
                   Platform.Equals(this.reverse, other.reverse));
        }
Exemplo n.º 3
0
        public override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }
            X509CertificatePair x509CertificatePair = obj as X509CertificatePair;

            if (x509CertificatePair == null)
            {
                return(false);
            }
            if (object.Equals((object)forward, (object)x509CertificatePair.forward))
            {
                return(object.Equals((object)reverse, (object)x509CertificatePair.reverse));
            }
            return(false);
        }
Exemplo n.º 4
0
		private void certPairTest()
		{
			X509CertificateParser certParser = new X509CertificateParser();

			X509Certificate rootCert = certParser.ReadCertificate(CertPathTest.rootCertBin);
			X509Certificate interCert = certParser.ReadCertificate(CertPathTest.interCertBin);
			X509Certificate finalCert = certParser.ReadCertificate(CertPathTest.finalCertBin);

			// Testing CollectionCertStore generation from List
			X509CertificatePair pair1 = new X509CertificatePair(rootCert, interCert);

			IList certList = new ArrayList();
			certList.Add(pair1);
			certList.Add(new X509CertificatePair(interCert, finalCert));

			IX509Store certStore = X509StoreFactory.Create(
				"CertificatePair/Collection",
				new X509CollectionStoreParameters(certList));

			X509CertPairStoreSelector selector = new X509CertPairStoreSelector();
			X509CertStoreSelector fwSelector = new X509CertStoreSelector();

			fwSelector.SerialNumber = rootCert.SerialNumber;
			fwSelector.Subject = rootCert.IssuerDN;

			selector.ForwardSelector = fwSelector;

			IList col = new ArrayList(certStore.GetMatches(selector));

			if (col.Count != 1 || !col.Contains(pair1))
			{
				Fail("failed pair1 test");
			}

			col = new ArrayList(certStore.GetMatches(null));

			if (col.Count != 2)
			{
				Fail("failed null test");
			}
		}
Exemplo n.º 5
0
		public override void PerformTest()
		{
			//CertificateFactory cf = CertificateFactory.getInstance("X.509");
			X509CertificateParser cf = new X509CertificateParser();

			X509Certificate rootCert = (X509Certificate) cf.ReadCertificate(CertPathTest.rootCertBin);
			X509Certificate interCert = (X509Certificate) cf.ReadCertificate(CertPathTest.interCertBin);
			X509Certificate finalCert = (X509Certificate) cf.ReadCertificate(CertPathTest.finalCertBin);

			X509CertificatePair pair1 = new X509CertificatePair(rootCert, interCert);
			X509CertificatePair pair2 = new X509CertificatePair(rootCert, interCert);
			X509CertificatePair pair3 = new X509CertificatePair(interCert, finalCert);
			X509CertificatePair pair4 = new X509CertificatePair(rootCert, finalCert);
			X509CertificatePair pair5 = new X509CertificatePair(rootCert, null);
			X509CertificatePair pair6 = new X509CertificatePair(rootCert, null);
			X509CertificatePair pair7 = new X509CertificatePair(null, rootCert);
			X509CertificatePair pair8 = new X509CertificatePair(null, rootCert);

			if (!pair1.Equals(pair2))
			{
				Fail("pair1 pair2 equality test");
			}

			if (!pair5.Equals(pair6))
			{
				Fail("pair1 pair2 equality test");
			}

			if (!pair7.Equals(pair8))
			{
				Fail("pair1 pair2 equality test");
			}

			if (pair1.Equals(null))
			{
				Fail("pair1 null equality test");
			}

			if (pair1.GetHashCode() != pair2.GetHashCode())
			{
				Fail("pair1 pair2 hashCode equality test");
			}

			if (pair1.Equals(pair3))
			{
				Fail("pair1 pair3 inequality test");
			}

			if (pair1.Equals(pair4))
			{
				Fail("pair1 pair4 inequality test");
			}

			if (pair1.Equals(pair5))
			{
				Fail("pair1 pair5 inequality test");
			}

			if (pair1.Equals(pair7))
			{
				Fail("pair1 pair7 inequality test");
			}

			if (pair5.Equals(pair1))
			{
				Fail("pair5 pair1 inequality test");
			}

			if (pair7.Equals(pair1))
			{
				Fail("pair7 pair1 inequality test");
			}

			if (pair1.Forward != rootCert)
			{
				Fail("pair1 forward test");
			}

			if (pair1.Reverse != interCert)
			{
				Fail("pair1 reverse test");
			}

			if (!AreEqual(pair1.GetEncoded(), pair2.GetEncoded()))
			{
				Fail("encoding check");
			}

			pair4 = new X509CertificatePair(rootCert, TestUtilities.CreateExceptionCertificate(false));

			try
			{
				pair4.GetEncoded();

				Fail("no exception on bad GetEncoded()");
			}
			catch (CertificateEncodingException)
			{
				// expected
			}

			pair4 = new X509CertificatePair(rootCert, TestUtilities.CreateExceptionCertificate(true));

			try
			{
				pair4.GetEncoded();

				Fail("no exception on exception GetEncoded()");
			}
			catch (CertificateEncodingException)
			{
				// expected
			}
		}