public void TestWithAttributeCertificate()
        {
            IList certList = new ArrayList();
            CmsProcessable msg = new CmsProcessableByteArray(Encoding.ASCII.GetBytes("Hello World!"));

            certList.Add(SignDsaCert);

            IX509Store x509Certs = X509StoreFactory.Create(
                "Certificate/Collection",
                new X509CollectionStoreParameters(certList));

            CmsSignedDataGenerator gen = new CmsSignedDataGenerator();

            gen.AddSigner(OrigKP.Private, OrigCert, CmsSignedDataGenerator.DigestSha1);

            gen.AddCertificates(x509Certs);

            IX509AttributeCertificate attrCert = CmsTestUtil.GetAttributeCertificate();

            ArrayList attrCerts = new ArrayList();
            attrCerts.Add(attrCert);

            IX509Store store = X509StoreFactory.Create(
                "AttributeCertificate/Collection",
                new X509CollectionStoreParameters(attrCerts));

            gen.AddAttributeCertificates(store);

            CmsSignedData sd = gen.Generate(msg);

            Assert.AreEqual(4, sd.Version);

            store = sd.GetAttributeCertificates("Collection");

            ArrayList coll = new ArrayList(store.GetMatches(null));

            Assert.AreEqual(1, coll.Count);

            Assert.IsTrue(coll.Contains(attrCert));

            //
            // create new certstore
            //
            certList = new ArrayList();
            certList.Add(OrigCert);
            certList.Add(SignCert);

            x509Certs = X509StoreFactory.Create(
                "Certificate/Collection",
                new X509CollectionStoreParameters(certList));

            //
            // replace certs
            //
            sd = CmsSignedData.ReplaceCertificatesAndCrls(sd, x509Certs, null, null);

            VerifySignatures(sd);
        }