diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-08-29 21:25:13 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-09-16 17:01:31 +0200 |
commit | 23ca0ad5ebcba3173ba3ff51e8114c33f795e62a (patch) | |
tree | ecf4c9ba3c1fa1ab35f8cdd8c71975be7d685818 /src/transports/ssh.c | |
parent | 2f5864c50c3c82d01837570cb0b7e629295c65cf (diff) | |
download | libgit2-23ca0ad5ebcba3173ba3ff51e8114c33f795e62a.tar.gz |
Bring certificate check back to the normal return code
Returning 0 lets the certificate check succeed. An error code is bubbled
up to the user.
Diffstat (limited to 'src/transports/ssh.c')
-rw-r--r-- | src/transports/ssh.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/transports/ssh.c b/src/transports/ssh.c index a25ab6315..8ea4a25d7 100644 --- a/src/transports/ssh.c +++ b/src/transports/ssh.c @@ -476,7 +476,6 @@ static int _git_ssh_setup_conn( if (t->owner->certificate_check_cb != NULL) { git_cert_hostkey cert; const char *key; - int allow; size_t certlen; cert.type = LIBSSH2_HOSTKEY_HASH_SHA1; @@ -498,16 +497,14 @@ static int _git_ssh_setup_conn( } /* We don't currently trust any hostkeys */ - allow = t->owner->certificate_check_cb(GIT_CERT_HOSTKEY_LIBSSH2, &cert, certlen, 0, t->owner->message_cb_payload); - if (allow < 0) { - error = allow; - goto on_error; - } - - if (!allow) { - error = GIT_ECERTIFICATE; - goto on_error; - } + giterr_clear(); + error = t->owner->certificate_check_cb(GIT_CERT_HOSTKEY_LIBSSH2, &cert, certlen, 0, t->owner->message_cb_payload); + if (error < 0) { + if (!giterr_last()) + giterr_set(GITERR_NET, "user cancelled hostkey check"); + + goto on_error; + } } /* we need the username to ask for auth methods */ |