Ejemplo n.º 1
0
        protected override bool isChangedKeyAccepted(string hostname, int port, string serverHostKeyAlgorithm,
                                                     byte[] serverHostKey)
        {
            AsyncController.AsyncDelegate d = delegate
            {
                _parent.CommandBox(String.Format(Locale.localizedString("Host key mismatch for {0}"), hostname),
                                   String.Format(Locale.localizedString("Host key mismatch for {0}"), hostname),
                                   String.Format(Locale.localizedString("The host key supplied is {0}."),
                                                 KnownHosts.createHexFingerprint(serverHostKeyAlgorithm, serverHostKey)),
                                   String.Format("{0}|{1}", Locale.localizedString("Allow"), Locale.localizedString("Deny")),
                                   false,
                                   isHostKeyDatabaseWritable() ? Locale.localizedString("Always") : null,
                                   SysIcons.Warning,
                                   Preferences.instance().getProperty("website.help") + "/" + Protocol.SFTP.getIdentifier(),
                                   delegate(int option, bool verificationChecked)
                {
                    switch (option)
                    {
                    case 0:
                        allow(hostname, serverHostKeyAlgorithm, serverHostKey, verificationChecked);
                        break;

                    case 1:
                        Log.warn("Cannot continue without a valid host key");
                        throw new ConnectionCanceledException();
                    }
                });
            };
            _parent.Invoke(d, true);
            return(true);
        }