libgit2 / libgit2sharp.nativebinaries

MIT License
29 stars 63 forks source link

Alpine 3.17: Could not load ssl libraries #141

Closed tonihW closed 1 year ago

tonihW commented 1 year ago

Using this image: https://github.com/dotnet/dotnet-docker/blob/main/src/aspnet/6.0/alpine3.17/amd64/Dockerfile Current alpine version: mcr.microsoft.com/dotnet/runtime:6.0.13-alpine3.17-amd64

When trying to clone a repository over HTTPS:

LibGit2Sharp.LibGit2SharpException: could not load ssl libraries
    at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 154
    at LibGit2Sharp.Core.Proxy.git_clone(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

I suspect this is a problem between these libgit2sharp native libraries and the openssl libraries in this specific alpine version.

bording commented 1 year ago

If there's a problem with OpenSSL and Alpine, then that is going to have to be solved upstream in libgit2 itself. Do you know which version of OpenSSL is being used in Alpine 3.17?

tonihW commented 1 year ago

Is it a problem with OpenSSL and Alpine? If I try to use the git executable or libgit2 library directly on the alpine image, OpenSSL works fine.

bording commented 1 year ago

or libgit2 library directly on the alpine image

Can you provide more info on what specifically you've done here? Which version of libgit2?

tonihW commented 1 year ago

Can you provide more info on what specifically you've done here? Which version of libgit2?

I tested some sample C code linking with libgit2 on alpine: https://libgit2.org/docs/guides/101-samples/

# apk add libgit2
fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/community/x86_64/APKINDEX.tar.gz
(1/4) Installing http-parser (2.9.4-r0)
(2/4) Installing pcre2 (10.42-r0)
(3/4) Installing libssh2 (1.10.0-r3)
(4/4) Installing libgit2 (1.5.0-r2)
OK: 24 MiB in 31 package

Anyways I've fixed my own problem by dropping this library as a dependency and creating a simple C# wrapper interface for Git executable. This way I can avoid having a dependency against a C library directly.

OpenSSL version: 3.0.7-r2