From 481ecb829e1bdd4e02a5dc7488d223e77446d40d Mon Sep 17 00:00:00 2001 From: Aidan Garske Date: Fri, 4 Dec 2026 14:29:30 -0800 Subject: [PATCH 1/3] Add a pinned Debian source option to install-openssl.sh for OpenSSL 3.5.5 --- debian/install-openssl.sh | 85 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 2 deletions(-) diff --git a/debian/install-openssl.sh b/debian/install-openssl.sh index 324be593..cb5ef0dd 100755 --- a/debian/install-openssl.sh +++ b/debian/install-openssl.sh @@ -60,6 +60,76 @@ openssl_clone() { cd $openssl_dir } +# Fetch one exact Debian openssl source package from snapshot.debian.org and +# rework its packaging to build and install on Debian 12. The .dsc sha256 is +# pinned and every tarball is checked against the digests the .dsc lists. +openssl_clone_pinned() { + local version=$1 + local stamp= dsc_sha256= f + case "$version" in + 3.5.5-1~deb13u1) + stamp=20260228T024510Z + dsc_sha256=9fef06359b7e7f0abfb0ac6869f7bb344ae7f8efb25d5969f004f278a877b146 + ;; + *) + echo "No pinned Debian source for openssl $version" >&2 + exit 1 + ;; + esac + local base="https://snapshot.debian.org/archive/debian/${stamp}/pool/main/o/openssl" + local dsc="openssl_${version}.dsc" + + printf "\tDownloading OpenSSL ${version} source from snapshot.debian.org\n" + apt-get update + apt-get install -y --no-install-recommends ca-certificates curl dpkg-dev \ + debhelper libzstd-dev zlib1g-dev + curl -fsSL --retry 3 -o "$dsc" "${base}/${dsc}" + echo "${dsc_sha256} ${dsc}" | sha256sum -c - || exit 1 + awk '/^Checksums-Sha256:/{on=1;next} /^[^ ]/{on=0} on{print $1 " " $3}' "$dsc" > "${dsc}.sha256" + [ -s "${dsc}.sha256" ] || { echo "No Checksums-Sha256 entries in $dsc" >&2; exit 1; } + for f in $(awk '{print $2}' "${dsc}.sha256"); do + curl -fsSL --retry 3 -o "$f" "${base}/${f}" + done + sha256sum -c "${dsc}.sha256" || exit 1 + # The archive signing key is not in Debian 12's keyring; the pinned .dsc + # digest and the tarball digests above stand in for the signature check. + dpkg-source --no-check -x "$dsc" + + openssl_dir=$(ls -td openssl-*/ | head -n 1) + printf "OpenSSL source directory: $openssl_dir\n" + cd $openssl_dir + openssl_backport_to_bookworm +} + +# Debian 13 packaging -> Debian 12: libssl3 again with the legacy provider in +# it, no FIPS provider (replace-default refuses one), and no Breaks, which +# name Debian 12's own openssh and would block the install. +openssl_backport_to_bookworm() { + local f + for f in debian/libssl3t64.*; do + mv "$f" "debian/libssl3.${f#debian/libssl3t64.}" + done + sed -i 's/libssl3t64/libssl3/g' debian/control debian/rules \ + debian/libssl3.symbols debian/libssl3.lintian-overrides + awk 'BEGIN{RS=""; ORS="\n\n"} + !/^Package: openssl-provider-(legacy|fips)\n/' debian/control > debian/control.new + mv debian/control.new debian/control + sed -i -e 's/dpkg-dev (>= [^)]*)/dpkg-dev/' \ + -e '/^Provides: \${t64:Provides}$/d' \ + -e '/^Replaces: libssl3$/d' \ + -e '/^Breaks: /d' \ + -e 's/, openssl-provider-legacy$//' debian/control + cat debian/openssl-provider-legacy.install >> debian/libssl3.install + rm -f debian/openssl-provider-legacy.install debian/openssl-provider-fips.install + sed -i 's/ enable-fips$//' debian/rules + sed -i '/fipsmodule.cnf/d' debian/not-installed + + if grep -q 't64\|openssl-provider-\|enable-fips' debian/control debian/rules; then + echo "Debian 12 backport of the openssl packaging is incomplete" >&2 + exit 1 + fi +} + openssl_patch_version() { local replace_default=${1:-0} printf "\tPatching OpenSSL version" @@ -145,6 +215,7 @@ openssl_install() { main() { local replace_default=0 local no_install=0 + local debian_source= local work_dir= local output_dir= @@ -159,10 +230,16 @@ main() { no_install=1 shift ;; + --debian-source) + debian_source=$2 + shift 2 + ;; -h|--help) echo "Usage: $0 [options]" echo " --replace-default Apply patch to replace default provider" echo " --no-install Build only, do not install packages" + echo " --debian-source VER Build this exact Debian openssl source version" + echo " (e.g. 3.5.5-1~deb13u1) instead of the release's own" echo " -h, --help Show this help message" echo "Arguments:" echo " output-directory Directory to to store built packages (default: mktemp -d)" @@ -185,7 +262,7 @@ main() { esac done - if [ $replace_default -eq 0 ] && [ $no_install -eq 0 ]; then + if [ $replace_default -eq 0 ] && [ $no_install -eq 0 ] && [ -z "$debian_source" ]; then printf "Using standard OpenSSL build\n" apt install -y --reinstall --allow-downgrades --allow-change-held-packages \ openssl libssl3 libssl-dev @@ -200,7 +277,11 @@ main() { printf "Working directory: $work_dir\n" pushd $work_dir 2>&1 > /dev/null - openssl_clone + if [ -n "$debian_source" ]; then + openssl_clone_pinned "$debian_source" + else + openssl_clone + fi openssl_patch $replace_default openssl_build From 6f1a74139efd1084713ef99f774dec6aee490711 Mon Sep 17 00:00:00 2001 From: Aidan Garske Date: Fri, 4 Dec 2026 15:09:28 -0800 Subject: [PATCH 2/3] Fetch the Debian OpenSSL source with apt from a named snapshot --- debian/install-openssl.sh | 57 +++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/debian/install-openssl.sh b/debian/install-openssl.sh index cb5ef0dd..5dd87045 100755 --- a/debian/install-openssl.sh +++ b/debian/install-openssl.sh @@ -60,40 +60,24 @@ openssl_clone() { cd $openssl_dir } -# Fetch one exact Debian openssl source package from snapshot.debian.org and -# rework its packaging to build and install on Debian 12. The .dsc sha256 is -# pinned and every tarball is checked against the digests the .dsc lists. -openssl_clone_pinned() { +# Fetch one exact Debian 13 openssl source version from a snapshot.debian.org +# archive snapshot that carries it, then rework its packaging for Debian 12. +# apt checks the snapshot's Release signature and the source hashes. +openssl_clone_snapshot() { local version=$1 - local stamp= dsc_sha256= f - case "$version" in - 3.5.5-1~deb13u1) - stamp=20260228T024510Z - dsc_sha256=9fef06359b7e7f0abfb0ac6869f7bb344ae7f8efb25d5969f004f278a877b146 - ;; - *) - echo "No pinned Debian source for openssl $version" >&2 - exit 1 - ;; - esac - local base="https://snapshot.debian.org/archive/debian/${stamp}/pool/main/o/openssl" - local dsc="openssl_${version}.dsc" + local snapshot=$2 + + if ! [[ "$version" =~ ^[0-9][0-9A-Za-z.+~-]*$ ]] || ! [[ "$snapshot" =~ ^[0-9]{8}T[0-9]{6}Z$ ]]; then + echo "Invalid --debian-source '$version' or --debian-snapshot '$snapshot'" >&2 + exit 1 + fi - printf "\tDownloading OpenSSL ${version} source from snapshot.debian.org\n" + printf "\tDownloading OpenSSL ${version} source from Debian snapshot ${snapshot}\n" + echo "deb-src [check-valid-until=no] http://snapshot.debian.org/archive/debian/${snapshot} trixie main" \ + > /etc/apt/sources.list.d/openssl-snapshot.list apt-get update - apt-get install -y --no-install-recommends ca-certificates curl dpkg-dev \ - debhelper libzstd-dev zlib1g-dev - curl -fsSL --retry 3 -o "$dsc" "${base}/${dsc}" - echo "${dsc_sha256} ${dsc}" | sha256sum -c - || exit 1 - awk '/^Checksums-Sha256:/{on=1;next} /^[^ ]/{on=0} on{print $1 " " $3}' "$dsc" > "${dsc}.sha256" - [ -s "${dsc}.sha256" ] || { echo "No Checksums-Sha256 entries in $dsc" >&2; exit 1; } - for f in $(awk '{print $2}' "${dsc}.sha256"); do - curl -fsSL --retry 3 -o "$f" "${base}/${f}" - done - sha256sum -c "${dsc}.sha256" || exit 1 - # The archive signing key is not in Debian 12's keyring; the pinned .dsc - # digest and the tarball digests above stand in for the signature check. - dpkg-source --no-check -x "$dsc" + apt-get install -y --no-install-recommends dpkg-dev debhelper libzstd-dev zlib1g-dev + apt-get source "openssl=${version}" openssl_dir=$(ls -td openssl-*/ | head -n 1) printf "OpenSSL source directory: $openssl_dir\n" @@ -216,6 +200,7 @@ main() { local replace_default=0 local no_install=0 local debian_source= + local debian_snapshot= local work_dir= local output_dir= @@ -234,12 +219,18 @@ main() { debian_source=$2 shift 2 ;; + --debian-snapshot) + debian_snapshot=$2 + shift 2 + ;; -h|--help) echo "Usage: $0 [options]" echo " --replace-default Apply patch to replace default provider" echo " --no-install Build only, do not install packages" - echo " --debian-source VER Build this exact Debian openssl source version" + echo " --debian-source VER Build this exact Debian 13 openssl source version" echo " (e.g. 3.5.5-1~deb13u1) instead of the release's own" + echo " --debian-snapshot TS snapshot.debian.org timestamp whose Debian 13 carries VER" + echo " (e.g. 20260320T000000Z); required with --debian-source" echo " -h, --help Show this help message" echo "Arguments:" echo " output-directory Directory to to store built packages (default: mktemp -d)" @@ -278,7 +269,7 @@ main() { pushd $work_dir 2>&1 > /dev/null if [ -n "$debian_source" ]; then - openssl_clone_pinned "$debian_source" + openssl_clone_snapshot "$debian_source" "$debian_snapshot" else openssl_clone fi From 35b0eeb1d962575a6d1c277cf2e4f021e78a6d3b Mon Sep 17 00:00:00 2001 From: Aidan Garske Date: Fri, 4 Dec 2026 16:42:05 -0800 Subject: [PATCH 3/3] Keep the Debian snapshot apt source private and require both source options --- debian/install-openssl.sh | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/debian/install-openssl.sh b/debian/install-openssl.sh index 5dd87045..23663ab6 100755 --- a/debian/install-openssl.sh +++ b/debian/install-openssl.sh @@ -66,6 +66,8 @@ openssl_clone() { openssl_clone_snapshot() { local version=$1 local snapshot=$2 + local apt_dir + local apt_opts if ! [[ "$version" =~ ^[0-9][0-9A-Za-z.+~-]*$ ]] || ! [[ "$snapshot" =~ ^[0-9]{8}T[0-9]{6}Z$ ]]; then echo "Invalid --debian-source '$version' or --debian-snapshot '$snapshot'" >&2 @@ -73,11 +75,20 @@ openssl_clone_snapshot() { fi printf "\tDownloading OpenSSL ${version} source from Debian snapshot ${snapshot}\n" - echo "deb-src [check-valid-until=no] http://snapshot.debian.org/archive/debian/${snapshot} trixie main" \ - > /etc/apt/sources.list.d/openssl-snapshot.list apt-get update apt-get install -y --no-install-recommends dpkg-dev debhelper libzstd-dev zlib1g-dev - apt-get source "openssl=${version}" + + # Private source list and list cache, so the system's apt never sees Debian 13. + apt_dir=$(mktemp -d) + chmod 755 "$apt_dir" + mkdir -p "$apt_dir/lists/partial" + echo "deb-src [check-valid-until=no] http://snapshot.debian.org/archive/debian/${snapshot} trixie main" \ + > "$apt_dir/sources.list" + apt_opts=(-o "Dir::Etc::sourcelist=$apt_dir/sources.list" -o "Dir::Etc::sourceparts=-" \ + -o "Dir::State::lists=$apt_dir/lists") + apt-get "${apt_opts[@]}" update + apt-get "${apt_opts[@]}" source "openssl=${version}" + rm -rf "$apt_dir" openssl_dir=$(ls -td openssl-*/ | head -n 1) printf "OpenSSL source directory: $openssl_dir\n" @@ -253,6 +264,13 @@ main() { esac done + if [ -z "$debian_source" ] || [ -z "$debian_snapshot" ]; then + if [ -n "$debian_source$debian_snapshot" ]; then + echo "--debian-source and --debian-snapshot must be given together" >&2 + exit 1 + fi + fi + if [ $replace_default -eq 0 ] && [ $no_install -eq 0 ] && [ -z "$debian_source" ]; then printf "Using standard OpenSSL build\n" apt install -y --reinstall --allow-downgrades --allow-change-held-packages \