libgit2 / libgit2sharp

Git + .NET = ❤
http://libgit2.github.com
MIT License
3.11k stars 876 forks source link

LibGit2SharpException: could not set credentials: could not open libssl #2061

Closed jhested closed 8 months ago

jhested commented 8 months ago

You are opening a bug report against the LibGit2Sharp project: we use GitHub Issues for tracking bug reports and feature requests. If you have a question about an API or usage, please ask on StackOverflow: http://stackoverflow.com/questions/tagged/libgit2sharp.

Otherwise, to report a bug, please fill out the reproduction steps (below) and delete these introductory paragraphs. Thanks!

Reproduction steps

Create a simple C# project and clone a repository over http Run on Ubuntu 22.04 on WSL

Expected behavior

Repository cloned

Actual behavior

Unhandled exception. LibGit2Sharp.LibGit2SharpException: could not set credentials: could not open libssl at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in //LibGit2Sharp/Core/Ensure.cs:line 154 at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in //LibGit2Sharp/Core/Ensure.cs:line 172 at LibGit2Sharp.Core.Proxy.gitclone(String url, String workdir, GitCloneOptions& opts) in //LibGit2Sharp/Core/Proxy.cs:line 278 at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, CloneOptions options) in /_/LibGit2Sharp/Repository.cs:line 793

Version of LibGit2Sharp (release number or SHA1)

0.27.2

Operating system(s) tested; .NET runtime tested

Ubuntu 22.04 on WSL

jhested commented 8 months ago

It seems like LibGit2Sharp is dependant on libssl 1.1 but Ubuntu 22.04 only comes with 3x

https://askubuntu.com/a/1483959

bording commented 8 months ago

@jhested LibGit2Sharp 0.27.2 should work fine with Ubuntu 22.04 and OpenSSL 3. The version of libgit2 used in that release can dynamically use libssl.so.3.

We already run tests on Ubuntu 22.04 that pass without problems. I also just reconfirmed it with a test app that calls Repository.Clone with both an http and http url.

If you can provide some actual code for me to try that reproduces the problem you're seeing, I can look into it further, but right now I'm not seeing anything wrong.

jhested commented 8 months ago

Hi @bording ,

Thanks for your reply, here is the code I'm using to test

public GitClient(GitClientOptions config) 
{
    _config = config;

    CloneOptions co = new CloneOptions();            

    co.CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials { Username = "x-access-token", Password = _config.PersonalAccessToken };

    _cloneOptions = co;
}

public string Clone(string url, string path, CancellationToken cancellationToken = default)
{
    return Repository.Clone(url, path, _cloneOptions);
}

FYI: I was able to get it working by manually installing openssl 1.1

bording commented 8 months ago

@jhested I've now also tested cloning a repo that requires credentials, and everything is still working fine, no OpenSSL 1.1 required.

Are you sure you're using LibGit2Sharp 0.27.2?

At this point I think I would need to see a fully working sample that reproduces the problem you're having, because all signs point to it being something other than LibGit2Sharp at this point.

jhested commented 8 months ago

@bording Thanks for taking your time to investigate this. I can no longer reproduce the error, after installing OpenSSL 1.1 manually, so I will setup a clean WSL later and test it again.

Will get back with the results tonight

jhested commented 8 months ago

@bording I have tested this out on a coworkers machines, and it worked perfectly on his. I will close the issue