/// <summary> /// Calls BIO_gets() /// </summary> /// <returns></returns> public string ReadString() { var sb = new StringBuilder(); const int BLOCK_SIZE = 64; var buf = new byte[BLOCK_SIZE]; var ret = 0; while (true) { ret = Native.BIO_gets(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()); }