private void CheckLink()
        {
            var syncInstance = Controller.GetSyncServerInstance(_serverAccountId);

            var messageHandler = new VerifyDeviceKeysResponseHandler(
                Controller.GetSyncServerInstance(_serverAccountId), _nonce);

            // Give the sync process a kick up the arse
            syncInstance.ProcessMessagesOnly();

            var replyReceived = messageHandler.WaitForReply();
            
            // Tell the sync process to go back to normal duties
            syncInstance.ProcessMessagesOnlyStop();

            if (!replyReceived)
            {
                MessageBox.Show(@"Device verification timed out");
                if (!_formClosed)
                    Invoke((MethodInvoker) Close);
                return;
            }

            var secretShareMessage = messageHandler.Reply;

            if (!secretShareMessage.Verified)
            {
                MessageBox.Show(@"Device verification denied.");
                if (!_formClosed)
                    Invoke((MethodInvoker)Close);
                return;
            }

            // Verify the signature against the public key we have for it.
            var account = Model.ServerAccounts.Get(_serverAccountId);
            var linkedClientCryptoKey = Model.CryptoKeys.Get(account.LinkedDeviceCryptoKeyId);
            var signatureVerified = AsymmetricCryptoUtil.VerifySignature(
                _nonce, messageHandler.Reply.NonceSigned, linkedClientCryptoKey.PublicKeyPem);

            if (!signatureVerified)
            {
                MessageBox.Show(@"Device verification failed.");
                messageHandler.MarkAsProcessed(false);
                if (!_formClosed)
                    Invoke((MethodInvoker)Close);
                return;
            }

            messageHandler.MarkAsProcessed(true);
            
            Model.CryptoKeys.Update(linkedClientCryptoKey.Id, new CryptoKey {Trust = true});

            Controller.UpdateHomePage();

            if (!_formClosed)
                Invoke((MethodInvoker) Close);
        }
        private void CheckLink()
        {
            var syncInstance = Controller.GetSyncServerInstance(_serverAccountId);

            var messageHandler = new VerifyDeviceKeysResponseHandler(
                Controller.GetSyncServerInstance(_serverAccountId), _nonce);

            // Give the sync process a kick up the arse
            syncInstance.ProcessMessagesOnly();

            var replyReceived = messageHandler.WaitForReply();

            // Tell the sync process to go back to normal duties
            syncInstance.ProcessMessagesOnlyStop();

            if (!replyReceived)
            {
                MessageBox.Show(@"Device verification timed out");
                if (!_formClosed)
                {
                    Invoke((MethodInvoker)Close);
                }
                return;
            }

            var secretShareMessage = messageHandler.Reply;

            if (!secretShareMessage.Verified)
            {
                MessageBox.Show(@"Device verification denied.");
                if (!_formClosed)
                {
                    Invoke((MethodInvoker)Close);
                }
                return;
            }

            // Verify the signature against the public key we have for it.
            var account = Model.ServerAccounts.Get(_serverAccountId);
            var linkedClientCryptoKey = Model.CryptoKeys.Get(account.LinkedDeviceCryptoKeyId);
            var signatureVerified     = AsymmetricCryptoUtil.VerifySignature(
                _nonce, messageHandler.Reply.NonceSigned, linkedClientCryptoKey.PublicKeyPem);

            if (!signatureVerified)
            {
                MessageBox.Show(@"Device verification failed.");
                messageHandler.MarkAsProcessed(false);
                if (!_formClosed)
                {
                    Invoke((MethodInvoker)Close);
                }
                return;
            }

            messageHandler.MarkAsProcessed(true);

            Model.CryptoKeys.Update(linkedClientCryptoKey.Id, new CryptoKey {
                Trust = true
            });

            Controller.UpdateHomePage();

            if (!_formClosed)
            {
                Invoke((MethodInvoker)Close);
            }
        }