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


C# PkixParameters.SetInitialPolicies方法代碼示例

本文整理匯總了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);
		}
開發者ID:KimikoMuffin,項目名稱:bc-csharp,代碼行數:53,代碼來源:NistCertPathTest.cs


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