Org.BouncyCastle.Pkix.PkixCertPath.PkixCertPath C# (CSharp) Method

PkixCertPath() public method

public PkixCertPath ( Stream inStream, String encoding ) : System
inStream Stream
encoding String
return System
		public PkixCertPath(
			Stream	inStream,
			String	encoding)
//			: base("X.509")
		{
			try
			{
				if (encoding.ToUpper().Equals("PkiPath".ToUpper()))
				{
					Asn1InputStream derInStream = new Asn1InputStream(inStream);
					Asn1Object derObject = derInStream.ReadObject();
					if (!(derObject is Asn1Sequence))
					{
						throw new CertificateException(
							"input stream does not contain a ASN1 SEQUENCE while reading PkiPath encoded data to load CertPath");
					}
					IEnumerator e = ((Asn1Sequence)derObject).GetEnumerator();
					Stream certInStream;
					MemoryStream outStream;
					DerOutputStream derOutStream;
					certificates = new ArrayList();

					while (e.MoveNext())
					{
						outStream = new MemoryStream();
						derOutStream = new DerOutputStream(outStream);

						derOutStream.WriteObject((Asn1Encodable)e.Current);
						derOutStream.Close();

						certInStream = new MemoryStream(outStream.ToArray(), false);
						certificates.Insert(0, new X509CertificateParser().ReadCertificate(certInStream));
					}
				}
				else if (encoding.ToUpper().Equals("PKCS7")
					|| encoding.ToUpper().Equals("PEM"))
				{
					inStream = new BufferedStream(inStream);
					certificates = new ArrayList();

					X509CertificateParser certParser = new X509CertificateParser();
					X509Certificate cert = null;

					while ((cert = certParser.ReadCertificate(inStream)) != null)
					{
						certificates.Add(cert);
					}
				}
				else
				{
					throw new CertificateException("unsupported encoding: " + encoding);
				}
			}
			catch (IOException ex)
			{
				throw new CertificateException(
					"IOException throw while decoding CertPath:\n"
					+ ex.ToString());
			}

			this.certificates = SortCerts(certificates);
		}
    

Same methods

PkixCertPath::PkixCertPath ( ) : System
PkixCertPath::PkixCertPath ( ICollection certificates ) : System
PkixCertPath::PkixCertPath ( Stream inStream ) : System