Skip to content

Commit 0acf2bf

Browse files
committed
avoid recording incorrect host key has changed errors
1 parent 7a6ff7f commit 0acf2bf

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/cargo/sources/git/known_hosts.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -395,19 +395,19 @@ fn check_ssh_known_hosts_loaded(
395395
KnownHostLineType::Key => {
396396
if key_matches {
397397
accepted_known_host_found = true;
398+
} else {
399+
// The host and key type matched, but the key itself did not.
400+
// This indicates the key has changed.
401+
// This is only reported as an error if no subsequent lines have a
402+
// correct key.
403+
latent_errors.push(KnownHostError::HostKeyHasChanged {
404+
hostname: host.to_string(),
405+
key_type: remote_key_type,
406+
old_known_host: known_host.clone(),
407+
remote_host_key: remote_host_key_encoded.clone(),
408+
remote_fingerprint: remote_fingerprint.clone(),
409+
});
398410
}
399-
400-
// The host and key type matched, but the key itself did not.
401-
// This indicates the key has changed.
402-
// This is only reported as an error if no subsequent lines have a
403-
// correct key.
404-
latent_errors.push(KnownHostError::HostKeyHasChanged {
405-
hostname: host.to_string(),
406-
key_type: remote_key_type,
407-
old_known_host: known_host.clone(),
408-
remote_host_key: remote_host_key_encoded.clone(),
409-
remote_fingerprint: remote_fingerprint.clone(),
410-
});
411411
}
412412
KnownHostLineType::Revoked => {
413413
if key_matches {

0 commit comments

Comments
 (0)