コード例 #1
0
        public void CanFindCertificateByCommonName()
        {
            var found = CertificateUtils.FindCertificates(
                StoreName.Root, StoreLocation.CurrentUser,
                "CN=Microsoft Root Certificate Authority, DC=microsoft, DC=com",
                X509FindType.FindBySubjectDistinguishedName, false)
                        .ToList();

            Assert.IsTrue(found.Count > 0);
        }
コード例 #2
0
        public void CanFindCertificateByThumbprint()
        {
            var certificate = CertificateUtils.GetCertificates(StoreName.My).First();

            Assert.NotNull(certificate.Thumbprint);

            string certificateThumbprint = certificate.Thumbprint;

            var found =
                CertificateUtils.FindCertificates(
                    StoreName.My, StoreLocation.CurrentUser, certificateThumbprint,
                    X509FindType.FindByThumbprint, false).ToList();

            Assert.AreEqual(1, found.Count);

            Assert.AreEqual(certificate, found.First());
        }