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)); }
/// <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>"); } }