Skip to content

Commit c7e7b61

Browse files
committed
Use libgit2 from "unstable" / "sid"
We received reports from users no longer being able to clone Git repositories using libgit2 because of errors during the cloning attempt: `error: Failed to authenticate SSH session: Unable to extract public key from private key.` After an extensive scavenger hunt I was able to pinpoint the issue to `libssh2` being linked against `libgcrypt` instead of `openssl`. The problem with this is that the libgcrypt backend in libssh2 contains a hand written slimmed down ASN.1 parser to read out keys, while the OpenSSL backend in libssh2 uses OpenSSL, which supports a lot more formats (and more specifically, most PKCS* formats). As Debian's bullseye/testing repository has been frozen, and a backport has not been made available yet, fetching the dependency from "unstable" seems to be the best option for now, as this has `libssh2` available including OpenSSL. Ref: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=668271 Signed-off-by: Hidde Beydals <hello@hidde.co>
1 parent 850157c commit c7e7b61

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

Dockerfile

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
FROM golang:1.16-buster as builder
22

33
# Up-to-date libgit2 dependencies are only available in
4-
# >=bullseye (testing).
5-
RUN echo "deb http://deb.debian.org/debian testing main" >> /etc/apt/sources.list \
6-
&& echo "deb-src http://deb.debian.org/debian testing main" >> /etc/apt/sources.list
4+
# unstable, as libssh2 in testing/bullseye has been linked
5+
# against gcrypt which causes issues with PKCS* formats.
6+
# Explicitly listing all build dependencies is required because
7+
# they can only be automagically found for AMD64 builds.
8+
# Ref: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=668271
9+
RUN echo "deb http://deb.debian.org/debian unstable main" >> /etc/apt/sources.list \
10+
&& echo "deb-src http://deb.debian.org/debian unstable main" >> /etc/apt/sources.list
711
RUN set -eux; \
812
apt-get update \
9-
&& apt-get install -y libgit2-dev/testing zlib1g-dev/testing libssh2-1-dev/testing libpcre3-dev/testing \
13+
&& apt-get install -y \
14+
libgit2-dev/unstable \
15+
zlib1g-dev/unstable \
16+
libssh2-1-dev/unstable \
17+
libpcre3-dev/unstable \
1018
&& apt-get clean \
1119
&& apt-get autoremove --purge -y \
1220
&& rm -rf /var/lib/apt/lists/*
@@ -38,12 +46,16 @@ FROM debian:buster-slim as controller
3846
LABEL org.opencontainers.image.source="https://github.com/fluxcd/source-controller"
3947

4048
# Up-to-date libgit2 dependencies are only available in
41-
# >=bullseye (testing).
42-
RUN echo "deb http://deb.debian.org/debian testing main" >> /etc/apt/sources.list \
43-
&& echo "deb-src http://deb.debian.org/debian testing main" >> /etc/apt/sources.list
49+
# unstable, as libssh2 in testing/bullseye has been linked
50+
# against gcrypt which causes issues with PKCS* formats.
51+
# Ref: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=668271
52+
RUN echo "deb http://deb.debian.org/debian unstable main" >> /etc/apt/sources.list \
53+
&& echo "deb-src http://deb.debian.org/debian unstable main" >> /etc/apt/sources.list
4454
RUN set -eux; \
4555
apt-get update \
46-
&& apt-get install -y ca-certificates libgit2-1.1 \
56+
&& apt-get install -y \
57+
ca-certificates \
58+
libgit2-1.1 \
4759
&& apt-get clean \
4860
&& apt-get autoremove --purge -y \
4961
&& rm -rf /var/lib/apt/lists/*
@@ -54,4 +66,4 @@ RUN groupadd controller && \
5466
useradd --gid controller --shell /bin/sh --create-home controller
5567

5668
USER controller
57-
ENTRYPOINT ["source-controller"]
69+
ENTRYPOINT [ "source-controller" ]

0 commit comments

Comments
 (0)