MemoryBuffer() public static method

Factory method that calls BIO_new() with BIO_s_mem()
public static MemoryBuffer ( ) : BIO
return BIO
Exemplo n.º 1
0
        private static DateTime AsnTimeToDateTime(IntPtr ptr)
        {
            string str;

            using (BIO bio = BIO.MemoryBuffer())
            {
                Native.ExpectSuccess(Native.ASN1_UTCTIME_print(bio.Handle, ptr));
                str = bio.ReadString();
            }
            string[] fmts =
            {
                "MMM  d HH:mm:ss yyyy G\\MT",
                "MMM dd HH:mm:ss yyyy G\\MT"
            };
            return(DateTime.ParseExact(str, fmts, new DateTimeFormatInfo(), DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Override of ToString() which uses Print() into a BIO memory buffer.
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            try {
                if (this.ptr == IntPtr.Zero)
                {
                    return("(null)");
                }

                using (BIO bio = BIO.MemoryBuffer()) {
                    this.Print(bio);
                    return(bio.ReadString());
                }
            }
            catch (Exception) {
                return("<exception>");
            }
        }