Mono.Tools.CertSync.DecodeCollection C# (CSharp) Method

DecodeCollection() static private method

static private DecodeCollection ( ) : X509CertificateCollection
return Mono.Security.X509.X509CertificateCollection
        static X509CertificateCollection DecodeCollection()
        {
            X509CertificateCollection roots = new X509CertificateCollection ();
            StringBuilder sb = new StringBuilder ();
            bool processing = false;

            using (Stream s = GetFile ()) {
                if (s == null) {
                    WriteLine ("Couldn't retrieve the file using the supplied information.");
                    return null;
                }

                StreamReader sr = new StreamReader (s);
                while (true) {
                    string line = sr.ReadLine ();
                    if (line == null)
                        break;

                    if (processing) {
                        if (line.StartsWith ("-----END CERTIFICATE-----")) {
                            processing = false;
                            X509Certificate root = DecodeCertificate (sb.ToString ());
                            roots.Add (root);

                            sb = new StringBuilder ();
                            continue;
                        }
                        sb.Append (line);
                    } else {
                        processing = line.StartsWith ("-----BEGIN CERTIFICATE-----");
                    }
                }
                return roots;
            }
        }