예제 #1
0
        public void GetDecryptionCertificateFromStore(StoreLocation location)
        {
            X509Store store = new X509Store(StoreName.My, location, OpenFlags.ReadOnly);

            foreach (var cert in store.Certificates)
            {
                if (cert.HasPrivateKey)
                {
                    Assert.AreEqual(cert, provider.FindDecryptionCertificate(cert.Thumbprint));
                }
                else
                {
                    Assert.Throws <CertificateValidationException>(() => provider.FindDecryptionCertificate(cert.Thumbprint));
                }
            }

            Assert.Throws <CertificateNotFoundException>(() => provider.FindDecryptionCertificate("ABCDE"));
        }