コード例 #1
0
ファイル: X509Chain.cs プロジェクト: edomurasaki2000/open_ssl
        /// <summary>
        /// Calls PEM_x509_INFO_read_bio()
        /// </summary>
        /// <param name="bio"></param>
        public X509List(BIO bio)
        {
            var sk = Native.ExpectNonNull(
                Native.PEM_X509_INFO_read_bio(bio.Handle, IntPtr.Zero, null, IntPtr.Zero));

            using (var stack = new Core.Stack <X509CertificateInfo>(sk, true))
            {
                while (stack.Count > 0)
                {
                    using (var xi = stack.Shift())
                    {
                        if (xi.Certificate != null)
                        {
                            Add(xi.Certificate);
                        }
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Creates a chain from a BIO. Expects the stream to contain
        /// a collection of X509_INFO objects in PEM format by calling
        /// PEM_X509_INFO_read_bio()
        /// </summary>
        /// <param name="bio"></param>
        public X509Chain(BIO bio)
        {
            IntPtr sk = Native.ExpectNonNull(Native.PEM_X509_INFO_read_bio(bio.Handle, IntPtr.Zero, null, IntPtr.Zero));

            using (Core.Stack <X509CertificateInfo> stack = new Core.Stack <X509CertificateInfo>(sk, true))
            {
                while (stack.Count > 0)
                {
                    using (X509CertificateInfo xi = stack.Shift())
                    {
                        X509Certificate cert = xi.Certificate;
                        if (cert != null)
                        {
                            this.Add(cert);
                        }
                    }
                }
            }
        }