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)); } }