Skip to content

TestRemoteSSH fails with libgit2 1.5 with built in SSH support #955

Open
@rrrrrrmb

Description

@rrrrrrmb

We have a bug report for git2go in Debian. The test for RemoteSSH fails with the following error :

=== NAME  TestRemoteSSH
>     remote_test.go:325: failed to handshake: <nil>, crypto/rsa: message too long for RSA key size
>     index_test.go:281: Fail at /<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/src/github.com/libgit2/git2go/v34/remote_test.go:511; failed to start SSH session: Unable to exchange encryption keys

Debian uses libgit2 1.5 with built-in SSH support for building git2go, you can find the full log of how we run the tests here. I'm not much familiar with go, but did a bit of reading and bumped the key size going by the error message. However that did not fix the failure. So I forced the use of managed SSH transport and that seems to fix the failure. The following patch is what I've applied to fix this in Debian. Could you provide any pointers on how to fix this with libgit2 bundled ssh support ?

--- a/remote_test.go 
+++ b/remote_test.go
@@ -447,7 +447,7 @@
        t.Parallel()
        pubKeyUsername := "testuser"

-       hostPrivKey, err := rsa.GenerateKey(rand.Reader, 512)
+       hostPrivKey, err := rsa.GenerateKey(rand.Reader, 2048)
        if err != nil {
                t.Fatalf("Failed to generate the host RSA private key: %v", err)
        }
@@ -456,7 +456,7 @@
                t.Fatalf("Failed to generate SSH hostSigner: %v", err)
        }

-       privKey, err := rsa.GenerateKey(rand.Reader, 512)
+       privKey, err := rsa.GenerateKey(rand.Reader, 2048)
        if err != nil {
                t.Fatalf("Failed to generate the user RSA private key: %v", err)
        }
--- a/git.go
+++ b/git.go
@@ -163,11 +163,11 @@
                // they're the only ones setting it up.
                C.git_openssl_set_locking()
        }
-       if features&FeatureSSH == 0 {
+//     if features&FeatureSSH == 0 {
                if err := registerManagedSSH(); err != nil {
                        panic(err)
                }
-       }
+//     }
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions