Methods
Public Instance methods
[ show source ]
# File lib/net/ssh/host-key-verifier.rb, line 7 7: def verify(arguments) 8: # first, find any matches on hostname+port 9: matches = keys.select do |item| 10: host = item[:host] || arguments[:peer][:host] 11: ip = item[:ip] || arguments[:peer][:ip] 12: port = item[:port] || arguments[:peer][:port] 13: 14: host == arguments[:peer][:host] && 15: ip == arguments[:peer][:ip] && 16: port == arguments[:peer][:port] 17: end 18: 19: # we've never seen this host before, so just automatically add the key. 20: # not the most secure option (since the first hit might be the one that 21: # is hacked), but since almost nobody actually compares the key 22: # fingerprint, this is a reasonable compromise between usability and 23: # security. 24: if matches.empty? 25: add_key(arguments) 26: return true 27: end 28: 29: # If we found any matches, check to see that the key type and 30: # blob also match. 31: found = matches.any? do |item| 32: item[:type] == arguments[:key].ssh_type && 33: item[:key] == arguments[:key_blob] 34: end 35: 36: # If a match was found, return true. Otherwise, raise an exception 37: # indicating that the key was not recognized. 38: found || process_cache_miss(arguments) 39: end