Beispiel #1
0
        public IAsyncResult BeginClientHandshake(string targetHost,
		                                         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, true);
                _handshakeSession = new ClientHandshakeSession(_securityParameters);
                _isHandshaking = true;
            }

            AsyncHandshakeResult asyncHandshakeResult = new AsyncHandshakeResult(asyncCallback, asyncState);
            ProcessSendHandshakePacket(asyncHandshakeResult);
            return asyncHandshakeResult;
        }
Beispiel #2
0
        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;
        }