public override void Write(byte[] buffer, int offset, int count) { IntPtr buf = Marshal.AllocHGlobal(count); Marshal.Copy(buffer, offset, buf, count); int writeCount; do { writeCount = OpenSSL.BIO_write(bio, buf, count); } while (writeCount <= 0 && OpenSSL.BIO_should_retry(bio)); OpenSSL.OpenSSLCheck(writeCount == count, "BIO_write"); Marshal.FreeHGlobal(buf); }