OpenSSL.Core.BIO.ReadString C# (CSharp) Method

ReadString() public method

Calls BIO_gets()
public ReadString ( ) : string
return string
		public string ReadString()
		{
			StringBuilder sb = new StringBuilder();
			const int BLOCK_SIZE = 64;
			byte[] buf = new byte[BLOCK_SIZE];
			int ret = 0;
			while (true)
			{
				ret = Native.BIO_gets(this.ptr, buf, buf.Length);
				if (ret == 0)
					break;
				if (ret < 0)
					throw new OpenSslException();

				sb.Append(Encoding.ASCII.GetString(buf, 0, ret));
			}
			return sb.ToString();
		}

Usage Example

Example #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));
        }
All Usage Examples Of OpenSSL.Core.BIO::ReadString