Skip to content

Commit

Permalink
avoid recording incorrect host key has changed errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hds committed Jan 31, 2023
1 parent 7a6ff7f commit 0acf2bf
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/cargo/sources/git/known_hosts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,19 +395,19 @@ fn check_ssh_known_hosts_loaded(
KnownHostLineType::Key => {
if key_matches {
accepted_known_host_found = true;
} else {
// The host and key type matched, but the key itself did not.
// This indicates the key has changed.
// This is only reported as an error if no subsequent lines have a
// correct key.
latent_errors.push(KnownHostError::HostKeyHasChanged {
hostname: host.to_string(),
key_type: remote_key_type,
old_known_host: known_host.clone(),
remote_host_key: remote_host_key_encoded.clone(),
remote_fingerprint: remote_fingerprint.clone(),
});
}

// The host and key type matched, but the key itself did not.
// This indicates the key has changed.
// This is only reported as an error if no subsequent lines have a
// correct key.
latent_errors.push(KnownHostError::HostKeyHasChanged {
hostname: host.to_string(),
key_type: remote_key_type,
old_known_host: known_host.clone(),
remote_host_key: remote_host_key_encoded.clone(),
remote_fingerprint: remote_fingerprint.clone(),
});
}
KnownHostLineType::Revoked => {
if key_matches {
Expand Down

0 comments on commit 0acf2bf

Please sign in to comment.