internal TcpListenerWebSocketContext(TcpClient client, bool secure, X509Certificate cert)
 {
     _client = client;
       _secure = secure;
       _stream = WsStream.CreateServerStream (client, secure, cert);
       _request = HandshakeRequest.Parse (_stream.ReadHandshake ());
       _websocket = new WebSocket (this);
 }
   internal TcpListenerWebSocketContext(
 TcpClient client, X509Certificate cert, bool secure, Logger logger)
   {
       _client = client;
         _secure = secure;
         _stream = WsStream.CreateServerStream (client, cert, secure);
         _request = _stream.ReadHandshake<HandshakeRequest> (
       HandshakeRequest.Parse, 90000);
         _websocket = new WebSocket (this, logger);
   }
    internal TcpListenerWebSocketContext (
      TcpClient client, string protocol, bool secure, X509Certificate cert, Logger logger)
    {
      _client = client;
      _secure = secure;
      _stream = WebSocketStream.CreateServerStream (client, secure, cert);
      _request = _stream.ReadHandshake<HandshakeRequest> (HandshakeRequest.Parse, 90000);
      _uri = HttpUtility.CreateRequestUrl (
        _request.RequestUri, _request.Headers ["Host"], _request.IsWebSocketRequest, secure);

      _websocket = new WebSocket (this, protocol, logger);
    }
Example #4
0
        private static async Task <string> GetAgentVersion(ServerAgent agent, CancellationToken token)
        {
            MessageClient messageClient = null;

            try {
                messageClient = new MessageClient(PhotonServer.Instance.MessageRegistry);
                await messageClient.ConnectAsync(agent.TcpHost, agent.TcpPort, token);

                var handshakeRequest = new HandshakeRequest {
                    Key           = Guid.NewGuid().ToString(),
                    ServerVersion = Configuration.Version,
                };

                var timeout           = TimeSpan.FromSeconds(30);
                var handshakeResponse = await messageClient.Handshake <HandshakeResponse>(handshakeRequest, timeout, token);

                if (!string.Equals(handshakeRequest.Key, handshakeResponse.Key, StringComparison.Ordinal))
                {
                    throw new ApplicationException("Handshake Failed! An invalid key was returned.");
                }

                if (!handshakeResponse.PasswordMatch)
                {
                    throw new ApplicationException("Handshake Failed! Unauthorized.");
                }

                var agentVersionRequest = new AgentGetVersionRequest();

                var agentVersionResponse = await messageClient.Send(agentVersionRequest)
                                           .GetResponseAsync <AgentGetVersionResponse>(token);

                return(agentVersionResponse.Version);
            }
            catch (Exception error) {
                throw new ApplicationException($"Failed to retrieve version of agent '{agent.Name}'!", error);
            }
            finally {
                messageClient?.Dispose();
            }
        }
            internal AutomaticProgressReporterTest(TimeSpan?interval = null, int expectedSentCount = 0)
            {
                _expectedSentCount = expectedSentCount;

                var payload = new HandshakeRequest(
                    ProtocolConstants.CurrentVersion,
                    ProtocolConstants.CurrentVersion);

                CancellationTokenSource = new CancellationTokenSource();
                Interval  = interval.HasValue ? interval.Value : ProtocolConstants.MaxTimeout;
                SentEvent = new ManualResetEventSlim(initialState: false);

                Connection = new Mock <IConnection>(MockBehavior.Strict);

                Connection.Setup(x => x.SendAsync(
                                     It.IsNotNull <Message>(),
                                     It.IsAny <CancellationToken>()))
                .Callback <Message, CancellationToken>(
                    (message, cancellationToken) =>
                {
                    ++_actualSentCount;

                    if (_actualSentCount >= expectedSentCount)
                    {
                        SentEvent.Set();
                    }
                })
                .Returns(Task.FromResult(0));

                Request = MessageUtilities.Create(
                    requestId: "a",
                    type: MessageType.Request,
                    method: MessageMethod.Handshake,
                    payload: payload);
                Reporter = AutomaticProgressReporter.Create(
                    Connection.Object,
                    Request,
                    Interval,
                    CancellationTokenSource.Token);
            }
Example #6
0
        public void Close_DisposesAllActiveInboundRequests()
        {
            using (var dispatcher = new MessageDispatcher(new RequestHandlers(), _idGenerator))
                using (var handlingEvent = new ManualResetEventSlim(initialState: false))
                    using (var blockingEvent = new ManualResetEventSlim(initialState: false))
                    {
                        var requestHandler = new RequestHandler();

                        Assert.True(dispatcher.RequestHandlers.TryAdd(MessageMethod.Handshake, requestHandler));

                        var connection = new Mock <IConnection>(MockBehavior.Strict);
                        var payload    = new HandshakeRequest(ProtocolConstants.CurrentVersion, ProtocolConstants.CurrentVersion);
                        var request    = dispatcher.CreateMessage(MessageType.Request, MessageMethod.Handshake, payload);

                        dispatcher.SetConnection(connection.Object);

                        var actualCancellationToken = default(CancellationToken);

                        requestHandler.HandleResponseAsyncFunc = (conn, message, responseHandler, cancellationToken) =>
                        {
                            handlingEvent.Set();

                            actualCancellationToken = cancellationToken;

                            blockingEvent.Set();

                            return(Task.FromResult(0));
                        };

                        connection.Raise(x => x.MessageReceived += null, new MessageEventArgs(request));

                        handlingEvent.Wait();

                        dispatcher.Close();

                        blockingEvent.Wait();

                        Assert.True(actualCancellationToken.IsCancellationRequested);
                    }
        }
Example #7
0
        public override async Task <HandshakeReply> DoHandshake(HandshakeRequest request, ServerCallContext context)
        {
            try
            {
                Logger.LogDebug($"Peer {context.Peer} has requested a handshake.");

                if (!UriHelper.TryParsePrefixedEndpoint(context.Peer, out IPEndPoint peerEndpoint))
                {
                    return new HandshakeReply {
                               Error = HandshakeError.InvalidConnection
                    }
                }
                ;

                return(await _connectionService.DoHandshakeAsync(peerEndpoint, request.Handshake));
            }
            catch (Exception e)
            {
                Logger.LogError(e, $"Handshake failed - {context.Peer}: ");
                throw;
            }
        }
        private async Task Verify(
            SemanticVersion requestedProtocolVersion,
            SemanticVersion requestedMinimumProtocolVersion,
            SemanticVersion negotiatedProtocolVersion)
        {
            using (var handshake = CreateHandshake())
            {
                var responseHandler = new Mock <IResponseHandler>(MockBehavior.Strict);

                responseHandler.Setup(x => x.SendResponseAsync(
                                          It.IsNotNull <Message>(),
                                          It.IsNotNull <HandshakeResponse>(),
                                          It.IsAny <CancellationToken>()))
                .Returns(Task.FromResult(0));

                var request        = new HandshakeRequest(requestedProtocolVersion, requestedMinimumProtocolVersion);
                var inboundMessage = new Message(
                    requestId: "a",
                    type: MessageType.Request,
                    method: MessageMethod.Handshake,
                    payload: JsonSerializationUtilities.FromObject(request));

                await handshake.HandleResponseAsync(
                    Mock.Of <IConnection>(),
                    inboundMessage,
                    responseHandler.Object,
                    CancellationToken.None);

                var expectedResponseCode = negotiatedProtocolVersion == null
                    ? MessageResponseCode.Error : MessageResponseCode.Success;

                responseHandler.Verify(x => x.SendResponseAsync(
                                           It.Is <Message>(message => message == inboundMessage),
                                           It.Is <HandshakeResponse>(response => response.ResponseCode == expectedResponseCode &&
                                                                     response.ProtocolVersion == negotiatedProtocolVersion),
                                           It.Is <CancellationToken>(token => !token.IsCancellationRequested)),
                                       Times.Once);
            }
        }
Example #9
0
    /// <inheritdoc />
    public bool TryConvert(HandshakeRequest request, out Request parsed, out Failure failure)
    {
        parsed = null;
        if (string.IsNullOrWhiteSpace(request.SdkIdentifier))
        {
            failure = new MissingHandshakeInformation(nameof(request.SdkIdentifier));
            return(false);
        }
        if (request.HeadVersion == null)
        {
            failure = new MissingHandshakeInformation(nameof(request.HeadVersion));
            return(false);
        }
        if (request.SdkVersion == null)
        {
            failure = new MissingHandshakeInformation(nameof(request.SdkVersion));
            return(false);
        }
        if (request.ContractsVersion == null)
        {
            failure = new MissingHandshakeInformation(nameof(request.ContractsVersion));
            return(false);
        }
        if (request.TimeSpent == null)
        {
            failure = new MissingHandshakeInformation(nameof(request.TimeSpent));
            return(false);
        }

        failure = null;
        parsed  = new Request(
            request.SdkIdentifier,
            request.SdkVersion.ToVersion(),
            request.HeadVersion.ToVersion(),
            request.ContractsVersion.ToVersion(),
            request.Attempt,
            request.TimeSpent.ToTimeSpan());
        return(true);
    }
        private async Task <object> ConnectToAgent()
        {
            Log.Debug($"Connecting to TCP Agent '{agent.TcpHost}:{agent.TcpPort}'...");

            try {
                await MessageClient.ConnectAsync(agent.TcpHost, agent.TcpPort, Token);

                Log.Info($"Connected to TCP Agent '{agent.TcpHost}:{agent.TcpPort}'.");

                var handshakeRequest = new HandshakeRequest {
                    Key           = Guid.NewGuid().ToString(),
                    ServerVersion = Configuration.Version,
                };

                var timeout           = TimeSpan.FromSeconds(HandshakeTimeoutSec);
                var handshakeResponse = await MessageClient.Handshake <HandshakeResponse>(handshakeRequest, timeout, Token);

                if (!string.Equals(handshakeRequest.Key, handshakeResponse.Key, StringComparison.Ordinal))
                {
                    throw new ApplicationException("Handshake Failed! An invalid key was returned.");
                }

                if (!handshakeResponse.PasswordMatch)
                {
                    throw new ApplicationException("Handshake Failed! Unauthorized.");
                }
            }
            catch (Exception error) {
                Log.Error($"Failed to connect to TCP Agent '{agent.TcpHost}:{agent.TcpPort}'!", error);
                MessageClient.Dispose();
                throw;
            }

            await OnBeginSession();

            Tasks.Start();
            return(null);
        }
 internal void SendAuthChallenge (string challenge)
 {
   var res = new HandshakeResponse (HttpStatusCode.Unauthorized);
   res.Headers ["WWW-Authenticate"] = challenge;
   _stream.WriteHandshake (res);
   _request = _stream.ReadHandshake<HandshakeRequest> (HandshakeRequest.Parse, 15000);
 }
Example #12
0
 public string GetAvailableSubProtocol()
 {
     return(HandshakeRequest.Get(WebSocketConstant.SecWebSocketProtocol));
 }
Example #13
0
        void AcceptConnection(TcpListener listener)
        {
            Socket newSocket;

            try
            {
                if (!listener.Server.IsBound)
                {
                    return;
                }

                newSocket = listener.AcceptSocket();
            }
            catch (Exception e)
            {
                /* TODO: Could have an exception here when listener 'goes away' when calling AcceptConnection! */
                /* Alternative would be to use locking but the listener doesn't go away without a reason. */
                Log.Write("server", "Accepting the connection failed.", e);
                return;
            }

            var newConn = new Connection {
                Socket = newSocket
            };

            try
            {
                newConn.Socket.Blocking = false;
                newConn.Socket.NoDelay  = true;

                // Validate player identity by asking them to sign a random blob of data
                // which we can then verify against the player public key database
                var token = Convert.ToBase64String(OpenRA.Exts.MakeArray(256, _ => (byte)Random.Next()));

                // Assign the player number.
                newConn.PlayerIndex = ChooseFreePlayerIndex();
                newConn.AuthToken   = token;

                // Send handshake and client index.
                var ms = new MemoryStream(8);
                ms.WriteArray(BitConverter.GetBytes(ProtocolVersion.Handshake));
                ms.WriteArray(BitConverter.GetBytes(newConn.PlayerIndex));
                SendData(newConn.Socket, ms.ToArray());

                PreConns.Add(newConn);

                // Dispatch a handshake order
                var request = new HandshakeRequest
                {
                    Mod       = ModData.Manifest.Id,
                    Version   = ModData.Manifest.Metadata.Version,
                    AuthToken = token
                };

                DispatchOrdersToClient(newConn, 0, 0, new Order("HandshakeRequest", null, false)
                {
                    Type         = OrderType.Handshake,
                    IsImmediate  = true,
                    TargetString = request.Serialize()
                }.Serialize());
            }
            catch (Exception e)
            {
                DropClient(newConn);
                Log.Write("server", "Dropping client {0} because handshake failed: {1}", newConn.PlayerIndex.ToString(CultureInfo.InvariantCulture), e);
            }
        }
Example #14
0
        private void SendHandshakeRequest(bool isReconnection)
        {
            IRequest request = new HandshakeRequest(Version, (!isReconnection) ? null : sessionToken, clientDetails);

            Send(request);
        }
Example #15
0
 public async override Task <CovidAllCountryReport> GetAllCountryReport(
     HandshakeRequest request, ServerCallContext context)
 {
     return(await _repository.GetAllCountryAsync());
 }
        public HttpResponseMessage PostHash(String hsID, [FromBody] HandshakeRequest hsRequest)
        {
            Handshake  h = new Handshake();
            Boolean    providerActive = false, providerIsPartner = false;
            int        employerID = 0;
            string     cnxString  = "";
            CCHEncrypt e          = new CCHEncrypt();

            using (ValidateMobilePartner vmp = new ValidateMobilePartner(hsID, hsRequest.OrganizationID))
            {
                vmp.ForEachProvider(delegate(Boolean valid, Boolean isPartner, int empId, string cnx, string un)
                {
                    providerActive    = valid;
                    providerIsPartner = isPartner;
                    employerID        = empId;
                    cnxString         = cnx;
                    Request.UserName(un);
                    MembershipUser mu = Membership.GetUser(un, true);
                    Request.UserID(mu.ProviderUserKey.ToString());
                });
            }

            if (providerActive && providerIsPartner)
            {
                e.UserKey   = Request.EncryptionKey();
                e.SecretKey = Properties.Settings.Default.SecretKey;
                e.Add("UserID", Request.UserID());

                e.Add("EmployerID", employerID.ToString());
                using (GetPartnerEmployeeInfoByName gpeibn = new GetPartnerEmployeeInfoByName())
                {
                    gpeibn.FirstName           = hsRequest.FirstName;
                    gpeibn.LastName            = hsRequest.LastName;
                    gpeibn.DOB                 = hsRequest.DOB;
                    gpeibn.SubscriberMedicalID = hsRequest.MedicalID;
                    //gpeibn.RelationshipCode = hsRequest.RelationshipCode;

                    gpeibn.GetData(cnxString);

                    if (gpeibn.Tables.Count == 0 ||
                        gpeibn.Tables[0].Rows.Count == 0 ||
                        gpeibn.Tables[0].Rows[0][0].ToString() == string.Empty)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NoContent, new Exception("User Not Found")));
                    }

                    //UserAccess Check dstrickland 7/8/2015
                    using (var cpaa = new CheckPersonApplicationAccess(gpeibn.CCHID, cnxString))
                    {
                        if (!cpaa.HasAccess)
                        {
                            return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized,
                                                               new Exception(cpaa.ErrorMessage)));
                        }
                    }

                    e.Add("CCHID", gpeibn.CCHID.ToString());
                    gpeibn.ForEach <Handshake.EmployeeInfoData>(
                        delegate(Handshake.EmployeeInfoData eid)
                    {
                        h.EmployeeInfo = eid;
                    }
                        );

                    //CreateLoginAudit(Request.UserName(), Request.RequestUri.Host.ToString(), gpeibn.CCHID, cnxString);
                    using (InsertUserLoginHistory iulh = new InsertUserLoginHistory())
                    {
                        iulh.UserName         = Request.UserName();
                        iulh.CCHID            = gpeibn.CCHID;
                        iulh.Domain           = Request.RequestUri.Host;
                        iulh.CchApplicationId = 2;  // 1 is for Transparency App; 2 is for HR App
                        iulh.PostData(cnxString);
                    }
                }

                h.AuthHash = e.ToString();
                return(this.Request.CreateResponse <Handshake>(HttpStatusCode.OK, h));
            }
            else
            {
                return(this.Request.CreateResponse(HttpStatusCode.Unauthorized));
            }
        }
Example #17
0
    public bool SendHandshake()
    {
      Debug.Log("Sending handshake to server.");

      HandshakeRequest handshakeRequest = new HandshakeRequest();
      PublicKey publicKey = this.LocalPublicKey;
      if (publicKey == null) {
        Debug.Warn("Client public key is invalid.");
        return false;
      }
      handshakeRequest.Key = publicKey;

      return this.SendMessage(MessageType.ClientHandshakeRequest, handshakeRequest, false);
    }
        public override void Handle(byte[] data, ClientConnectionInfo connection)
        {
            var handshakeRequest = new HandshakeRequest(data);

            _gameServer.PacketSenderManager.SendHandshakeResponse(connection, handshakeRequest.ProtocolVersion == 1 ? HandshakeResponseCode.OK : HandshakeResponseCode.INVALID_VERSION);
        }
Example #19
0
        private bool ReadTls(TlsConnection connection)
        {
            if (connection.Buffer.Avaliable < 5) //Header
            {
                return(false);
            }

            byte contentType = connection.Buffer.Read();

            connection.Buffer.ReadIndex += 2; //Version
            int length = connection.Buffer.ReadShort();

            if (connection.Buffer.Avaliable < length)
            {
                return(false);
            }

            int packetEnd = connection.Buffer.ReadIndex + length;

            if (connection.RecvEncrypted)
            {
                var aes = new AesManaged
                {
                    BlockSize = 128,
                    Key       = connection.ClientWriteKey,
                    IV        = connection.Buffer.Read(16),
                    Padding   = PaddingMode.PKCS7
                };

                byte[] data = aes.CreateDecryptor().TransformFinalBlock(connection.Buffer.Read(length - 16), 0,
                                                                        length - 16);

                length = data.Length - 21; //21 - Padding + Hash
                Buffer.BlockCopy(data, 0, connection.Buffer.Data, connection.Buffer.WriteIndex, length);
                connection.Buffer.WriteIndex += length;
                packetEnd = connection.Buffer.ReadIndex + length;
            }

            switch (contentType)
            {
            case 20:     // ChangeCipherSpec
                Log.Info("Recv ClientChangeCipherSpec");
                connection.InitCipher();
                connection.RecvEncrypted = true;
                break;

            case 21:     // Alert
                break;

            case 22:     // Handshake
            {
                byte[] data = new byte[length];
                Buffer.BlockCopy(connection.Buffer.Data, connection.Buffer.ReadIndex, data, 0, length);
                connection.HandshakeMessages.AddRange(data);

                byte handshakeType   = connection.Buffer.Read();
                int  handshakeLength = connection.Buffer.ReadShortInt();

                switch (handshakeType)
                {
                case 1:
                    HandshakeRequest.ClientHello(connection, handshakeLength);
                    break;

                case 16:
                    HandshakeRequest.ClientKeyExchange(connection, handshakeLength);
                    break;

                case 20:
                    HandshakeRequest.ClientFinish(connection, handshakeLength);
                    break;

                default:
                    Log.ErrorFormat("Unknown handshakeType: {0}", handshakeType);
                    break;
                }
            }
            break;

            case 23:     // Message
            {
                string[] message = Encoding.ASCII.GetString(connection.Buffer.Read(length))
                                   .Split(_messageSeparators, StringSplitOptions.RemoveEmptyEntries);

                ProcessStsHeader(connection, message[0]);
                GtSGlobal.AuthEngine.ProcessStsConnection(connection, connection.Request, message.Length > 1 ? message[1] : "");
            }
            break;

            default:
                Log.ErrorFormat("Unknown tls contentType: {0}", contentType);
                break;
            }

            connection.Buffer.ReadIndex += packetEnd - connection.Buffer.ReadIndex;

            return(true);
        }
        private static Uri createRequestUrl(HandshakeRequest request, bool secure)
        {
            var host = request.Headers ["Host"];
              if (host == null || host.Length == 0)
            return null;

              string scheme = null;
              string path = null;

              var reqUri = request.RequestUri;
              if (reqUri.StartsWith ("/")) {
            path = reqUri;
              }
              else if (reqUri.MaybeUri ()) {
            Uri uri;
            if (!Uri.TryCreate (reqUri, UriKind.Absolute, out uri) ||
            !uri.Scheme.StartsWith ("ws"))
              return null;

            scheme = uri.Scheme;
            host = uri.Authority;
            path = uri.PathAndQuery;
              }
              else if (reqUri == "*") {
              }
              else {
            // As authority form
            host = reqUri;
              }

              if (scheme == null)
            scheme = secure ? "wss" : "ws";

              var colon = host.IndexOf (':');
              if (colon == -1)
            host = String.Format ("{0}:{1}", host, scheme == "ws" ? 80 : 443);

              var url = String.Format ("{0}://{1}{2}", scheme, host, path);

              Uri res;
              if (!Uri.TryCreate (url, UriKind.Absolute, out res))
            return null;

              return res;
        }
Example #21
0
        private void SendHandshakeRequest(bool isReconnection)
        {
            IRequest request = new HandshakeRequest(this.Version, (!isReconnection) ? null : this.sessionToken, this.clientDetails);

            this.Send(request);
        }
Example #22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="isReconnection"></param>
        private void SendHandshakeRequest(bool isReconnection)
        {
            IRequest request = new HandshakeRequest(Version, !isReconnection ? null : sessionToken);

            Send(request);
        }
Example #23
0
 public override async Task <HandshakeReply> DoHandshake(HandshakeRequest request, ServerCallContext context)
 {
     Logger.LogDebug($"Peer {context.GetPeerInfo()} has requested a handshake.");
     return(await _connectionService.CheckIncomingHandshakeAsync(context.GetPublicKey(), request.Handshake));
 }
Example #24
0
    /// <inheritdoc />
    public override async Task <HandshakeResponse> Handshake(HandshakeRequest request, ServerCallContext context)
    {
        try
        {
            if (!_requestConverter.TryConvert(request, out var parsedRequest, out var failure))
            {
                Log.RequestParsingFailed(_logger, failure.Reason);
                return(FailedResponse(failure));
            }

            Log.HeadInitiatedHandshake(
                _logger,
                parsedRequest.Attempt,
                parsedRequest.HeadVersion,
                parsedRequest.SDK,
                parsedRequest.SDKVersion,
                parsedRequest.ContractsVersion);

            switch (_contractsCompatibility.CheckCompatibility(_runtimeContractsVersion, parsedRequest.ContractsVersion))
            {
            case ContractsCompatibility.ClientTooOld:
                Log.ClientContractsVersionTooOld(_logger, parsedRequest.ContractsVersion, _runtimeContractsVersion);
                return(FailedResponse(new SDKMustBeUpdated(_runtimeContractsVersion)));

            case ContractsCompatibility.RuntimeTooOld:
                Log.RuntimeContractsVersionTooOld(_logger, parsedRequest.ContractsVersion, _runtimeContractsVersion);
                return(FailedResponse(new RuntimeMustBeUpdated(parsedRequest.ContractsVersion)));
            }

            var platformEnvironment = await _platformEnvironment.Resolve().ConfigureAwait(false);

            Log.SuccessfulHandshake(
                _logger,
                parsedRequest.HeadVersion,
                parsedRequest.SDK,
                parsedRequest.SDKVersion,
                platformEnvironment.MicroserviceId,
                platformEnvironment.Environment,
                parsedRequest.Attempt,
                parsedRequest.TimeSpent);

            var otlpConfig = _openTelemetryConfig.Value;
            var response   = new HandshakeResponse
            {
                RuntimeVersion   = _runtimeVersion.ToProtobuf(),
                ContractsVersion = _runtimeContractsVersion.ToProtobuf(),
                CustomerId       = platformEnvironment.CustomerId.ToProtobuf(),
                CustomerName     = platformEnvironment.CustomerName.Value,
                ApplicationId    = platformEnvironment.ApplicationId.ToProtobuf(),
                ApplicationName  = platformEnvironment.ApplicationName.Value,
                MicroserviceId   = platformEnvironment.MicroserviceId.ToProtobuf(),
                MicroserviceName = platformEnvironment.MicroserviceName.Value,
                EnvironmentName  = platformEnvironment.Environment.Value,
            };

            if (otlpConfig.Tracing && !string.IsNullOrEmpty(otlpConfig.Endpoint))
            {
                response.OtlpEndpoint = otlpConfig.Endpoint;
            }

            return(response);
        }
        catch (Exception ex)
        {
            Log.ErrorWhilePerformingHandshake(_logger, ex);
            return(FailedResponse(new Failure {
                Id = FailureId.Other.ToProtobuf(), Reason = ex.Message
            }));
        }
    }