diff options
author | zeripath <art27@cantab.net> | 2020-03-28 17:24:55 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-28 19:24:55 +0200 |
commit | ea67e563dd9fc20e508d41079ea00312b880ac82 (patch) | |
tree | 0e66a5157866ae99f84995f7478fc6c05d2dd26d /models/ssh_key.go | |
parent | f9f2c163b12f60a6bf9c3652cdc4bdf59e3d53c4 (diff) | |
download | gitea-ea67e563dd9fc20e508d41079ea00312b880ac82.tar.gz gitea-ea67e563dd9fc20e508d41079ea00312b880ac82.zip |
Use ErrKeyUnableToVerify if fail to calc fingerprint in ssh-keygen (#10863)
* Use ErrKeyUnableToVerify if fail to calc fingerprint in ssh-keygen
Fix #3985
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Pass up the unable to verify
Diffstat (limited to 'models/ssh_key.go')
-rw-r--r-- | models/ssh_key.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/models/ssh_key.go b/models/ssh_key.go index 1e1cdad404..33ba86c5bf 100644 --- a/models/ssh_key.go +++ b/models/ssh_key.go @@ -425,6 +425,9 @@ func calcFingerprintSSHKeygen(publicKeyContent string) (string, error) { defer os.Remove(tmpPath) stdout, stderr, err := process.GetManager().Exec("AddPublicKey", "ssh-keygen", "-lf", tmpPath) if err != nil { + if strings.Contains(stderr, "is not a public key file") { + return "", ErrKeyUnableVerify{stderr} + } return "", fmt.Errorf("'ssh-keygen -lf %s' failed with error '%s': %s", tmpPath, err, stderr) } else if len(stdout) < 2 { return "", errors.New("not enough output for calculating fingerprint: " + stdout) @@ -455,6 +458,10 @@ func calcFingerprint(publicKeyContent string) (string, error) { fp, err = calcFingerprintSSHKeygen(publicKeyContent) } if err != nil { + if IsErrKeyUnableVerify(err) { + log.Info("%s", publicKeyContent) + return "", err + } return "", fmt.Errorf("%s: %v", fnName, err) } return fp, nil |