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


C# PkixCertPath.GetEncoded方法代碼示例

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


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

示例1: PerformTest

		public override void PerformTest()
		{
			X509CertificateParser cf = new X509CertificateParser();

			X509Certificate rootCert = cf.ReadCertificate(rootCertBin);
			X509Certificate interCert = cf.ReadCertificate(interCertBin);
			X509Certificate finalCert = cf.ReadCertificate(finalCertBin);

			//Testing CertPath generation from List
			IList list = new ArrayList();
			list.Add(interCert);
//			CertPath certPath1 = cf.generateCertPath(list);
			PkixCertPath certPath1 = new PkixCertPath(list);

			//Testing CertPath encoding as PkiPath
			byte[] encoded = certPath1.GetEncoded("PkiPath");

			//Testing CertPath generation from InputStream
			MemoryStream inStream = new MemoryStream(encoded, false);
//			CertPath certPath2 = cf.generateCertPath(inStream, "PkiPath");
			PkixCertPath certPath2 = new PkixCertPath(inStream, "PkiPath");

			//Comparing both CertPathes
			if (!certPath2.Equals(certPath1))
			{
				Fail("CertPath differ after encoding and decoding.");
			}

			encoded = certPath1.GetEncoded("PKCS7");

			//Testing CertPath generation from InputStream
			inStream = new MemoryStream(encoded, false);
//			certPath2 = cf.generateCertPath(inStream, "PKCS7");
			certPath2 = new PkixCertPath(inStream, "PKCS7");

			//Comparing both CertPathes
			if (!certPath2.Equals(certPath1))
			{
				Fail("CertPath differ after encoding and decoding.");
			}

			encoded = certPath1.GetEncoded("PEM");

			//Testing CertPath generation from InputStream
			inStream = new MemoryStream(encoded, false);
//			certPath2 = cf.generateCertPath(inStream, "PEM");
			certPath2 = new PkixCertPath(inStream, "PEM");

			//Comparing both CertPathes
			if (!certPath2.Equals(certPath1))
			{
				Fail("CertPath differ after encoding and decoding.");
			}

			//
			// empty list test
			//
			list = new ArrayList();

//			CertPath certPath = CertificateFactory.GetInstance("X.509","BC").generateCertPath(list);
			PkixCertPath certPath = new PkixCertPath(list);
			if (certPath.Certificates.Count != 0)
			{
				Fail("list wrong size.");
			}

			//
			// exception tests
			//
			doTestExceptions();
		}
開發者ID:KimikoMuffin,項目名稱:bc-csharp,代碼行數:71,代碼來源:CertPathTest.cs


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