Fix fallback for failed ssh public key auth

This commit is contained in:
Jesse van den Kieboom 2014-12-25 12:12:10 +01:00
parent 795c4f17fe
commit 1f0f2a415c
2 changed files with 5 additions and 3 deletions

View file

@ -249,7 +249,7 @@ public class CredentialsManager
string? username,
Ggit.Credtype allowed_types) throws Error
{
if (d_remote.authentication_error != null && (allowed_types & Ggit.Credtype.SSH_KEY) != 0)
if (d_remote.authentication_error == null && (allowed_types & Ggit.Credtype.SSH_KEY) != 0)
{
return new Ggit.CredSshKeyFromAgent(username);
}

View file

@ -113,8 +113,10 @@ public class Remote : Ggit.Remote
catch (Error e)
{
// NOTE: need to check the message for now in case of failed
// http auth.
if (e.message == "Unexpected HTTP status code: 401")
// http or ssh auth. This is fragile and will likely break
// in future libgit2 releases. Please fix!
if (e.message == "Unexpected HTTP status code: 401" ||
e.message == "error authenticating: Username/PublicKey combination invalid")
{
d_authentication_error = e;
continue;