Skip to content

Commit 8338d41

Browse files
chore(rootfs): build custom openssl debs for nginx
this cleans up the image by avoiding to versions of openssl 1.1.1 in the same image by replacing the default ubuntu openssl packages with custom built ones that are fully backwards compatible.
1 parent b75142d commit 8338d41

1 file changed

Lines changed: 27 additions & 19 deletions

File tree

rootfs/Dockerfile

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,38 @@ WORKDIR /tmp/build
3838
RUN set -x && \
3939
apt-get update && \
4040
apt-get install -y --no-install-recommends \
41-
g++ make patch perl
41+
build-essential fakeroot software-properties-common devscripts
4242

4343
RUN set -x && \
44-
export OPENSSL_VERSION=1.1.1g OPENSSL_SIGNING_KEY=8657ABB260F056B1E5190839D9C4D26D0E604491 BUILD_PATH=$PWD PREFIX=/usr/local && \
45-
get_src_gpg $OPENSSL_SIGNING_KEY "https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz" && \
44+
export OPENSSL_VERSION=1.1.1g BUILD_PATH=$PWD DEBEMAIL="Team Hephy <team@teamhephy.com>" && \
45+
add-apt-repository --enable-source ppa:ondrej/nginx && \
46+
apt-get build-dep -y openssl=$OPENSSL_VERSION && \
47+
apt-get source -y openssl=$OPENSSL_VERSION && \
4648
# ChaCha20-Poly1305 Draft Support for older Android versions
4749
get_src_file 5e082d46544915b0a580fe71a5e53cb22f535c7dc67a35221d292316701dc085 \
4850
https://raw.githubusercontent.com/hakasenyang/openssl-patch/3ea9038/openssl-1.1.1f-chacha_draft.patch && \
4951
# Allow setting equal preference and TLSv1.3 ciphers in NGINX
5052
get_src_file 04f682c36405a908247c27e317fb0f5f5bb19cbac9699f5afa21fd81511e6be2 \
5153
https://raw.githubusercontent.com/hakasenyang/openssl-patch/e3bd4a8/openssl-equal-1.1.1e-dev_ciphers.patch && \
5254
cd "$BUILD_PATH/openssl-$OPENSSL_VERSION" && \
53-
patch -p1 -i "$BUILD_PATH/openssl-1.1.1f-chacha_draft.patch" && \
54-
patch -p1 -i "$BUILD_PATH/openssl-equal-1.1.1e-dev_ciphers.patch" && \
55-
./config --prefix=/usr/local \
56-
--openssldir=/etc/ssl \
57-
shared enable-weak-ssl-ciphers && \
58-
make -j`nproc` && \
59-
make install_sw
55+
sed -i '/^CONFARGS\s*=/ s/ enable-unit-test//' debian/rules && \
56+
dch -l hephy "Disable unit tests" && \
57+
sed -i '/^CONFARGS\s*=/ s/$/ enable-weak-ssl-ciphers/' debian/rules && \
58+
dch -l hephy "Enable weak SSL ciphers" && \
59+
cp "$BUILD_PATH/openssl-equal-1.1.1e-dev_ciphers.patch" debian/patches/ && \
60+
echo openssl-equal-1.1.1e-dev_ciphers.patch >> debian/patches/series && \
61+
dch -l hephy "Add BoringSSL port of equal preference cipher groups" && \
62+
cp "$BUILD_PATH/openssl-1.1.1f-chacha_draft.patch" debian/patches/ && \
63+
echo openssl-1.1.1f-chacha_draft.patch >> debian/patches/series && \
64+
# Add missing libcrypto 1.1.1f symbol mapping
65+
sed -i '/^ \*@OPENSSL_1_1_1e 1\.1\.1e/p; s/e/f/g' debian/libssl1.1.symbols && \
66+
dch -l hephy "Add ChaCha-Draft cipher support" && \
67+
dch -r " " && \
68+
DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -uc -b -rfakeroot && \
69+
cd .. && \
70+
dpkg-scanpackages . > Packages && \
71+
mkdir ../repo && \
72+
mv Packages *.deb ../repo
6073

6174
FROM hephy/base:v0.4.1
6275

@@ -68,30 +81,25 @@ RUN adduser --system \
6881
router
6982

7083
COPY --from=modsecurity /usr/local /usr/local
71-
COPY --from=openssl /usr/local /usr/local
84+
COPY --from=openssl /tmp/repo /usr/local/repo
7285

7386
COPY /bin /bin
7487

7588
RUN set -x && \
76-
buildDeps='gcc make patch libgeoip-dev libmaxminddb-dev libpcre3-dev' \
77-
runtimeDeps='ca-certificates libcurl4 libxml2 libpcre3 libgeoip1 libmaxminddb0 libfuzzy2' && \
89+
buildDeps='gcc make patch libgeoip-dev libmaxminddb-dev libpcre3-dev libssl-dev' \
90+
runtimeDeps='ca-certificates libcurl4 libxml2 libpcre3 libgeoip1 libmaxminddb0 libfuzzy2 libssl1.1 openssl' && \
91+
echo 'deb [trusted=yes] file:/usr/local/repo ./' >> /etc/apt/sources.list && \
7892
apt-get update && \
7993
apt-get install -y --no-install-recommends \
8094
$buildDeps \
8195
$runtimeDeps && \
82-
# Remove openssl binaries from base image, will be provided by our custom build
83-
apt-get remove -y openssl && \
8496
export NGINX_VERSION=1.18.0 SIGNING_KEY=B0F4253373F8F6F510D42178520A9993A1C052F8 \
8597
CLOUDFLARE_ZLIB_VERSION=372bcd151c901418c2721232bf09dc9cdbebafb5 \
8698
VTS_VERSION=0.1.18 GEOIP2_VERSION=3.3 \
8799
MOD_SECURITY_NGINX_VERSION=e50e43ee4cc87565922ed98b1b6c72751019c326 \
88100
OWASP_MOD_SECURITY_CRS_VERSION=cf57fd53de06b87b90d2cc5d61d602df81b2dd70 \
89101
BUILD_PATH=/tmp/build PREFIX=/opt/router && \
90102
ldconfig && \
91-
# Provide custom openssl binaries in standard /usr/bin location
92-
update-alternatives --verbose \
93-
--install /usr/bin/openssl openssl /usr/local/bin/openssl 1 \
94-
--slave /usr/bin/c_rehash c_rehash /usr/local/bin/c_rehash && \
95103
rm -rf "$PREFIX" && \
96104
mkdir "$PREFIX" && \
97105
mkdir "$BUILD_PATH" && \

0 commit comments

Comments
 (0)