Merge pull request #13805 from AaronFriel/friel/fix-ssh-key-check

Use exported interface to detect SSH key type
This commit is contained in:
Kubernetes Prow Robot 2022-06-15 22:44:49 -07:00 committed by GitHub
commit f1a948b4f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -73,15 +73,15 @@ func ComputeAWSKeyFingerprint(publicKey string) (string, error) {
return "", err
}
switch fmt.Sprintf("%T", sshPublicKey) {
case "*ssh.rsaPublicKey":
switch sshPublicKey.Type() {
case ssh.KeyAlgoRSA:
der, err := rsaToDER(sshPublicKey)
if err != nil {
return "", fmt.Errorf("error computing fingerprint for SSH public key: %v", err)
}
h := md5.Sum(der)
return colonSeparatedHex(h[:]), nil
case "ssh.ed25519PublicKey":
case ssh.KeyAlgoED25519:
return ssh.FingerprintSHA256(sshPublicKey), nil
}