Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mdb571 opened this issue Oct 2, 2023 · 0 comments
Open

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

mdb571 opened this issue Oct 2, 2023 · 0 comments

Comments

@mdb571
Copy link

mdb571 commented Oct 2, 2023

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)
                }
-       }
+//     }
 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant