Exemple #1
0
        private bool AskUserReliability(ISSHHostKeyInformationProvider info, string keystr, string message_text_id)
        {
            //比較結果に基づく処理
            IPoderosaForm form = UsabilityPlugin.Instance.WindowManager.ActiveWindow;

            Debug.Assert(form.AsForm().InvokeRequired); //別スレッドで実行しているはず

            //fingerprint
            StringBuilder bld = new StringBuilder();

            byte[] fingerprint = info.HostKeyFingerPrint;
            for (int i = 0; i < fingerprint.Length; i++)
            {
                if (bld.Length > 0)
                {
                    bld.Append(':');
                }
                bld.Append(fingerprint[i].ToString("x2"));
            }

            string message = String.Format("ssh hostkey fingerprint {0}\n\n{1}", bld.ToString(), UsabilityPlugin.Strings.GetString(message_text_id));

            if (form.AskUserYesNo(message) == DialogResult.Yes)
            {
                Update(info, keystr, true);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        public bool Verify(ISSHHostKeyInformationProvider info)
        {
            if (!_loaded)
            {
                try {
                    Load();
                }
                catch (Exception ex) { //ロード中のエラーのときは鍵は拒否。安全側に!
                    RuntimeUtil.ReportException(ex);
                    return(false);
                }
            }

            string keystr = info.KnownHostsString;
            string local  = (info.Protocol == SSHProtocol.SSH1) ? _dataForSSH1[ToKeyString(info)] : _dataForSSH2[ToKeyString(info)];

            if (local == null)
            {
                return(AskUserReliability(info, keystr, "Message.HostKeyChecker.AskHostKeyRegister"));
            }
            else if (keystr != local)
            {
                return(AskUserReliability(info, keystr, "Message.HostKeyChecker.AskHostKeyRenew"));
            }
            else
            {
                return(true);
            }
        }
 public bool Vefiry(ISSHHostKeyInformationProvider info)
 {
     if (_verifier == null)
         _verifier = FindHostKeyVerifier();
     if (_verifier == null)
         return true; //普通KnownHostsくらいはあるだろう。エラーにすべきかもしれないが
     else
         return _verifier.Verify(info);
 }
Exemple #4
0
        private static string ToKeyString(ISSHHostKeyInformationProvider info)
        {
            string h = info.HostName;

            if (info.PortNumber != 22)
            {
                h += ":" + info.PortNumber;
            }
            return(h);
        }
Exemple #5
0
 public bool Vefiry(ISSHHostKeyInformationProvider info)
 {
     if (_verifier == null)
     {
         _verifier = FindHostKeyVerifier();
     }
     if (_verifier == null)
     {
         return(true); //普通KnownHostsくらいはあるだろう。エラーにすべきかもしれないが
     }
     else
     {
         return(_verifier.Verify(info));
     }
 }
Exemple #6
0
        private void Update(ISSHHostKeyInformationProvider info, string key, bool flush)
        {
            if (info.Protocol == SSHProtocol.SSH1)
            {
                _dataForSSH1[ToKeyString(info)] = key;
            }
            else
            {
                _dataForSSH2[ToKeyString(info)] = key;
            }

            _modified = true;
            if (flush)
            {
                Flush();
            }
        }
 private bool CheckKey(ISSHHostKeyInformationProvider info)
 {
     SetIgnoreTimeout(); //これが呼ばれるということは途中までSSHのネゴシエートができているのでタイムアウトはしないようにする
     return _keycheck(info);
 }
Exemple #8
0
 private bool CheckKey(ISSHHostKeyInformationProvider info)
 {
     SetIgnoreTimeout(); //これが呼ばれるということは途中までSSHのネゴシエートができているのでタイムアウトはしないようにする
     return(_keycheck(info));
 }
 //ISSHHostKeyVerifier
 public bool Verify(ISSHHostKeyInformationProvider provider)
 {
     return(_acceptsHostKey);
 }
        private void Update(ISSHHostKeyInformationProvider info, string key, bool flush)
        {
            if (info.Protocol == SSHProtocol.SSH1)
                _dataForSSH1[ToKeyString(info)] = key;
            else
                _dataForSSH2[ToKeyString(info)] = key;

            _modified = true;
            if (flush)
                Flush();
        }
        private bool AskUserReliability(ISSHHostKeyInformationProvider info, string keystr, string message_text_id)
        {
            //比較結果に基づく処理
            IPoderosaForm form = UsabilityPlugin.Instance.WindowManager.ActiveWindow;
            Debug.Assert(form.AsForm().InvokeRequired); //別スレッドで実行しているはず

            //fingerprint
            StringBuilder bld = new StringBuilder();
            byte[] fingerprint = info.HostKeyFingerPrint;
            for (int i = 0; i < fingerprint.Length; i++) {
                if (bld.Length > 0)
                    bld.Append(':');
                bld.Append(fingerprint[i].ToString("x2"));
            }

            string message = String.Format("ssh hostkey fingerprint {0}\n\n{1}", bld.ToString(), UsabilityPlugin.Strings.GetString(message_text_id));

            if (form.AskUserYesNo(message) == DialogResult.Yes) {
                Update(info, keystr, true);
                return true;
            }
            else
                return false;
        }
 private static string ToKeyString(ISSHHostKeyInformationProvider info)
 {
     string h = info.HostName;
     if (info.PortNumber != 22)
         h += ":" + info.PortNumber;
     return h;
 }
        public bool Verify(ISSHHostKeyInformationProvider info)
        {
            if (!_loaded) {
                try {
                    Load();
                }
                catch (Exception ex) { //ロード中のエラーのときは鍵は拒否。安全側に!
                    RuntimeUtil.ReportException(ex);
                    return false;
                }
            }

            string keystr = info.KnownHostsString;
            string local = (info.Protocol == SSHProtocol.SSH1) ? _dataForSSH1[ToKeyString(info)] : _dataForSSH2[ToKeyString(info)];

            if (local == null) {
                return AskUserReliability(info, keystr, "Message.HostKeyChecker.AskHostKeyRegister");
            }
            else if (keystr != local) {
                return AskUserReliability(info, keystr, "Message.HostKeyChecker.AskHostKeyRenew");
            }
            else
                return true;
        }