public static mx509.X509Certificate OpenSslX509ToMonoX509(ox509.X509Certificate cert) { BIO bio = BIO.MemoryBuffer(true); cert.Write(bio); byte[] raw = new byte[bio.BytesPending]; bio.Read(raw, raw.Length); bio.Dispose(); return(new mx509.X509Certificate(raw)); }
override protected bool HandleOutgoing(ICopyable app_data, out ICopyable data) { MemBlock buffer = null; data = null; int written = 1; lock (_buffer_sync) { if (app_data != null) { int count = app_data.CopyTo(_buffer, 0); written = _ssl.Write(_buffer, count); } if (written > 0) { int count = _write.Read(_buffer, _buffer.Length); if (count <= 0) { // This really shouldn't ever happen ProtocolLog.WriteIf(ProtocolLog.SecurityExceptions, this + " error"); data = null; return(false); } buffer = MemBlock.Copy(_buffer, 0, count); } } if (written > 0) { // Timer becomes -1 when there are no more control messages long to = _ssl.GetTimeout(); if (to >= 0) { HandleWouldBlock(); } if (buffer != null) { data = new CopyList(PType, Header, buffer); return(true); } } // If the write failed, then Dtls is either waiting for a control message // or has a control message to send var error = _ssl.GetError(written); if (error == SslError.SSL_ERROR_WANT_READ) { HandleWouldBlock(); } else if (error == SslError.SSL_ERROR_SSL) { var ose = new OpenSslException(); Close("Received unrecoverable error: " + ose.ToString()); throw ose; } else { ProtocolLog.WriteIf(ProtocolLog.SecurityExceptions, "Send other"); } data = null; return(false); }