public bool Write(byte[] buffer, int offset, int count)
 {
     if (this.ssl != null)
     {
         try
         {
             this.ssl.Write(buffer, offset, count);
             return(true);
         }
         catch
         {
             clib.imsg("Write to socket failed");
             this.ssl.Close();
             this.ssl = (SslStreamM)null;
             return(false);
         }
     }
     else
     {
         try
         {
             this.send_blocks(this._conn, buffer, offset, count);
             return(true);
         }
         catch (Exception ex)
         {
             clib.imsg("write failed {0}", (object)ex.Message);
             return(false);
         }
     }
 }
 public void JustClose()
 {
     if (this.ssl != null)
     {
         this.ssl.Close();
         this.ssl = (SslStreamM)null;
     }
     if (this._conn == null || !this._conn.Connected)
     {
         return;
     }
     this._conn.Shutdown(SocketShutdown.Both);
     this._conn.Close();
     this._conn = (Socket)null;
 }
        private void OnAuthenticateAsServer(IAsyncResult result)
        {
            SslStreamM sslStream = (SslStreamM)null;

            try
            {
                sslStream = result.AsyncState as SslStreamM;
                sslStream.EndAuthenticateAsServer(result);
                this.connectionCallback((object)this, new SecureConnectionResults(sslStream));
            }
            catch (Exception ex)
            {
                sslStream?.Dispose();
                this.connectionCallback((object)this, new SecureConnectionResults(ex));
            }
        }
        private void OnAcceptConnection(IAsyncResult result)
        {
            TcpListener asyncState = result.AsyncState as TcpListener;
            SslStreamM  sslStreamM = (SslStreamM)null;

            try
            {
                if (!this.started)
                {
                    return;
                }
                asyncState.BeginAcceptTcpClient(this.onAcceptConnection, (object)asyncState);
                TcpClient tcpClient            = asyncState.EndAcceptTcpClient(result);
                bool      leaveInnerStreamOpen = false;
                sslStreamM = this.certValidationCallback == null ? new SslStreamM((Stream)tcpClient.GetStream(), leaveInnerStreamOpen) : new SslStreamM((Stream)tcpClient.GetStream(), leaveInnerStreamOpen, this.certValidationCallback);
                sslStreamM.BeginAuthenticateAsServer(this.serverCert, false, this.sslProtocols, this.checkCertifcateRevocation, this.onAuthenticateAsServer, (object)sslStreamM);
            }
            catch (Exception ex)
            {
                sslStreamM?.Dispose();
                this.connectionCallback((object)this, new SecureConnectionResults(ex));
            }
        }
示例#5
0
 internal SecureConnectionResults(SslStreamM sslStream)
 {
     this.secureStream = sslStream;
 }