public PkixCertPath(Stream inStream, string encoding) { string text = encoding.ToUpper(); IList list; try { if (text.Equals("PkiPath".ToUpper())) { Asn1InputStream asn1InputStream = new Asn1InputStream(inStream); Asn1Object asn1Object = asn1InputStream.ReadObject(); if (!(asn1Object is Asn1Sequence)) { throw new CertificateException("input stream does not contain a ASN1 SEQUENCE while reading PkiPath encoded data to load CertPath"); } list = Platform.CreateArrayList(); using (IEnumerator enumerator = ((Asn1Sequence)asn1Object).GetEnumerator()) { while (enumerator.MoveNext()) { Asn1Encodable asn1Encodable = (Asn1Encodable)enumerator.Current; byte[] encoded = asn1Encodable.GetEncoded("DER"); Stream inStream2 = new MemoryStream(encoded, false); list.Insert(0, new X509CertificateParser().ReadCertificate(inStream2)); } goto IL_EF; } } if (!text.Equals("PKCS7") && !text.Equals("PEM")) { throw new CertificateException("unsupported encoding: " + encoding); } list = Platform.CreateArrayList(new X509CertificateParser().ReadCertificates(inStream)); IL_EF :; } catch (IOException ex) { throw new CertificateException("IOException throw while decoding CertPath:\n" + ex.ToString()); } this.certificates = PkixCertPath.SortCerts(list); }
public PkixCertPath(ICollection certificates) { this.certificates = PkixCertPath.SortCerts(Platform.CreateArrayList(certificates)); }