本文整理汇总了C#中Org.BouncyCastle.Pkix.PkixParameters.SetInitialPolicies方法的典型用法代码示例。如果您正苦于以下问题:C# PkixParameters.SetInitialPolicies方法的具体用法?C# PkixParameters.SetInitialPolicies怎么用?C# PkixParameters.SetInitialPolicies使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Org.BouncyCastle.Pkix.PkixParameters
的用法示例。
在下文中一共展示了PkixParameters.SetInitialPolicies方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoTest
private PkixCertPathValidatorResult DoTest(
string trustAnchor,
string[] certs,
string[] crls,
ISet policies)
{
ISet trustedSet = new HashSet();
trustedSet.Add(GetTrustAnchor(trustAnchor));
IList x509Certs = new ArrayList();
IList x509Crls = new ArrayList();
X509Certificate endCert = LoadCert(certs[certs.Length - 1]);
for (int i = 0; i != certs.Length - 1; i++)
{
x509Certs.Add(LoadCert(certs[i]));
}
x509Certs.Add(endCert);
PkixCertPath certPath = new PkixCertPath(x509Certs);
for (int i = 0; i != crls.Length; i++)
{
x509Crls.Add(LoadCrl(crls[i]));
}
IX509Store x509CertStore = X509StoreFactory.Create(
"Certificate/Collection",
new X509CollectionStoreParameters(x509Certs));
IX509Store x509CrlStore = X509StoreFactory.Create(
"CRL/Collection",
new X509CollectionStoreParameters(x509Crls));
// CertPathValidator validator = CertPathValidator.GetInstance("PKIX");
PkixCertPathValidator validator = new PkixCertPathValidator();
PkixParameters parameters = new PkixParameters(trustedSet);
parameters.AddStore(x509CertStore);
parameters.AddStore(x509CrlStore);
parameters.IsRevocationEnabled = true;
if (policies != null)
{
parameters.IsExplicitPolicyRequired = true;
parameters.SetInitialPolicies(policies);
}
// Perform validation as of this date since test certs expired
parameters.Date = new DateTimeObject(DateTime.Parse("1/1/2011"));
return validator.Validate(certPath, parameters);
}