libgit2 / libgit2sharp

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

Failed to load ssl libraries error on Alpine #2009

Closed Ay1000 closed 7 months ago

Ay1000 commented 1 year ago

Reproduction steps

Try to Clone a Git repo from a .net 7 project running in a mcr.microsoft.com/dotnet/aspnet:7.0-alpine image.

Expected behavior

Clone successful

Actual behavior

Error: LibGit2Sharp.LibGit2SharpException: could not load ssl libraries 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.0-preview-0182

Operating system(s) tested; .NET runtime tested

mcr.microsoft.com/dotnet/aspnet:7.0-alpine

Ay1000 commented 1 year ago

Hi @bording

Do you have any ideas, a direction for me perhaps?

Ay1000 commented 1 year ago

downgraded to 6.0-alpine3.16 which still has the OLD openssl libraries, that fixed the problem.

But this still leaves us with security issues. So will leave this ticket open

ps:

bording commented 1 year ago

@Ay100 If the latest preview isn't working, then there's likely nothing that can be done at the LibGit2Sharp level, but would need some sort of change at the libgit2 level.

libgit2 dynamically loads the OpenSSL dependency, so if that code isn't working, it would need to change there.

Do you know what's different about OpenSSL between the two docker images?

ymor commented 1 year ago

I'm also facing the same issue, however I have a working version on .net 7.0.1 using alpine 3.16 and the broken version is .net 7.0.2 using alpine 3.17 so I'm going to say the most likely place of the issue is from the new alpine version which includes OpenSSL3 as the default OpenSSL version.

It looks like someone is currently working on this support on libgit2 https://github.com/libgit2/libgit2/commit/f02bcf721105d3dfb0a7d12dec2816b495451c45

ymor commented 1 year ago

@Ay1000 Installing the openssl1.1-compat package seems to resolve the issue for me. using the mcr.microsoft.com/dotnet/aspnet:7.0-alpine image

bording commented 1 year ago

As I suspected, this appears to be related to the version of OpenSSL that the newer version of Alpine is using, and it not being supported by libgit2 yet: https://github.com/libgit2/libgit2/pull/6471

bording commented 7 months ago

In case you haven't already tried the newer releases, this should be resolved now.