public IAsyncResult BeginServerHandshake(X509Certificate serverCertificate, AsyncCallback asyncCallback, Object asyncState) { lock (_handshakeLock) { if (_isHandshaking) { throw new InvalidOperationException("Handshake already in progress"); } if (_isAuthenticated) { throw new InvalidOperationException("Renegotiation not supported"); } _recordHandler = new RecordHandler(_securityParameters.MinimumVersion, false); _handshakeSession = new ServerHandshakeSession(_securityParameters); _isHandshaking = true; } AsyncHandshakeResult asyncHandshakeResult = new AsyncHandshakeResult(asyncCallback, asyncState); _recordStream.BeginReceive(new AsyncCallback(ReceiveHandshakeCallback), asyncHandshakeResult); return(asyncHandshakeResult); }