本文整理汇总了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));
}
示例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));
}
示例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;
}
}