當前位置: 首頁>>代碼示例>>C#>>正文


C# X509Chain.VerifyWithExtraRoots方法代碼示例

本文整理匯總了C#中System.Security.Cryptography.X509Certificates.X509Chain.VerifyWithExtraRoots方法的典型用法代碼示例。如果您正苦於以下問題:C# X509Chain.VerifyWithExtraRoots方法的具體用法?C# X509Chain.VerifyWithExtraRoots怎麽用?C# X509Chain.VerifyWithExtraRoots使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Security.Cryptography.X509Certificates.X509Chain的用法示例。


在下文中一共展示了X509Chain.VerifyWithExtraRoots方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SelfSignedTest

        public void SelfSignedTest()
        {
            var chain = new X509Chain();
            var trusted = new X509Certificate2Collection();

            Assert.IsFalse(chain.Build(Certificates.SelfSigned));
            Assert.IsFalse(chain.VerifyWithExtraRoots(Certificates.SelfSigned, trusted));

            trusted.Add(Certificates.SelfSigned);
            Assert.IsTrue(chain.VerifyWithExtraRoots(Certificates.SelfSigned, trusted));
            Assert.IsFalse(chain.Build(Certificates.SelfSigned));

            trusted.Clear();
            Assert.IsFalse(chain.VerifyWithExtraRoots(Certificates.SelfSigned, trusted));
            Assert.IsFalse(chain.Build(Certificates.SelfSigned));
        }
開發者ID:conjurinc,項目名稱:api-dotnet,代碼行數:16,代碼來源:CertificateVerificationTest.cs

示例2: SelfSignedRootTest

        public void SelfSignedRootTest()
        {
            var chain = new X509Chain();
            var trusted = new X509Certificate2Collection();
            chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck;

            Assert.IsFalse(chain.Build(Certificates.SignedBySelfSigned));
            Assert.IsFalse(chain.VerifyWithExtraRoots(Certificates.SignedBySelfSigned, trusted));

            trusted.Add(Certificates.SelfSigned);
            Assert.IsTrue(chain.VerifyWithExtraRoots(Certificates.SignedBySelfSigned, trusted));
            Assert.IsFalse(chain.Build(Certificates.SignedBySelfSigned));

            trusted.Clear();
            Assert.IsFalse(chain.VerifyWithExtraRoots(Certificates.SignedBySelfSigned, trusted));
            Assert.IsFalse(chain.Build(Certificates.SignedBySelfSigned));
        }
開發者ID:conjurinc,項目名稱:api-dotnet,代碼行數:17,代碼來源:CertificateVerificationTest.cs

示例3: ValidateCertificate

 /// <summary>
 /// Validates the Conjur appliance certificate. 
 /// <see cref="RemoteCertificateValidationCallback"/> 
 /// </summary>
 /// <returns><c>true</c>, if certificate was valid, <c>false</c> otherwise.</returns>
 /// <param name="sender">Sender of the validation request.</param>
 /// <param name="certificate">Certificate to be validated.</param>
 /// <param name="chain">Certificate chain, as resolved by the system.</param>
 /// <param name="sslPolicyErrors">SSL policy errors from the system.</param>
 private bool ValidateCertificate(
     object sender, 
     X509Certificate certificate, 
     X509Chain chain, 
     SslPolicyErrors sslPolicyErrors)
 {
     switch (sslPolicyErrors)
     {
         case SslPolicyErrors.RemoteCertificateChainErrors:
             return chain.VerifyWithExtraRoots(certificate, this.TrustedCertificates);
         case SslPolicyErrors.None:
             return true;
         default:
             return false;
     }
 }
開發者ID:conjurinc,項目名稱:api-dotnet,代碼行數:25,代碼來源:Client.cs


注:本文中的System.Security.Cryptography.X509Certificates.X509Chain.VerifyWithExtraRoots方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。