Skip to content

Commit

Permalink
Add an option to fix Let's Encrypt CA certificates for old distros (#450
Browse files Browse the repository at this point in the history
)
  • Loading branch information
mlocati committed Oct 7, 2021
1 parent f5a8f0f commit 73545ba
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,9 @@ Here's the list of all the supported environment variables:

| Extension | Environment variable | Description |
|---|---|---|
| | `IPE_FIX_CACERTS=1` | Old Alpine Linux (3.7 and 3.8) and Debian (Jessie and Stretch) versions don't work anymore with websites whose HTTPS certificate has been signed by Let's Encrypt ([more details here](https://letsencrypt.org/docs/dst-root-ca-x3-expiration-september-2021/).<br /> By setting this environment variable, `install-php-extensions` will fix this issue |
| | `IPE_KEEP_SYSPKG_CACHE=1` | By default the script will clear the apt/apk/pear cache in order to save disk space. You can disable it by setting this environment variable |
| lzf | `IPE_LZF_BETTERCOMPRESSION=1` | By default `install-php-extensions` compiles the `lzf` extension to prefer speed over size; you can use this environment variable to compile it preferring size over speed |
| lzf | `IPE_LZF_BETTERCOMPRESSION=1` | By default `install-php-extensions` compiles the `lzf` extension to prefer speed over size; you can use this environment variable to compile it preferring size over speed |
| event | `IPE_EVENT_NAMESPACE=`... | By default the `event` classes are defined in the root namespace. You can use this environment variable to specify a custom namespace |
| gd | IPE_GD_WITHOUTAVIF=1 | Since PHP 8.1, gd supports the AVIF format. Enabling it requires compiling libaom/libdav1d/libyuv/libavif, which is time-consuming. You can disable AVIF support by setting this environment variable |

Expand Down
44 changes: 44 additions & 0 deletions install-php-extensions
Original file line number Diff line number Diff line change
Expand Up @@ -2991,6 +2991,48 @@ removeStringFromList() {
printf '%s' "$removeStringFromList_result"
}

# Replace the list of trusted CA with toe ones provided by cURL.
# (controlled by IPE_FIX_CACERTS is set)
fixCACerts() {
case "${IPE_FIX_CACERTS:-}" in
1 | y* | Y*) ;;
*)
return
;;
esac
case "$DISTRO_VERSION" in
alpine@3.7 | alpine@3.8) ;;
debian@8 | debian@9)
if ! grep -q 'mozilla/ISRG_Root_X1.crt' /etc/ca-certificates.conf && grep -q 'mozilla/DST_Root_CA_X3.crt' /etc/ca-certificates.conf; then
fixCACerts_mustUpdate=1
if test -d /var/lib/apt/lists; then
for fixCACerts_item in $(ls -1 /var/lib/apt/lists); do
case "$fixCACerts_item" in
partial | lock) ;;
*)
fixCACerts_mustUpdate=0
break
;;
esac
done
fi
if test $fixCACerts_mustUpdate -eq 1; then
DEBIAN_FRONTEND=noninteractive apt-get update -q
fi
apt-get install -qqy --no-install-recommends ca-certificates
fi
;;
*)
# No needs to update the CA list
return
;;
esac
if grep -Eq '^mozilla/ISRG_Root_X1\.crt$' /etc/ca-certificates.conf && grep -Eq '^mozilla/DST_Root_CA_X3\.crt$' /etc/ca-certificates.conf; then
sed -i '/^mozilla\/DST_Root_CA_X3/s/^/!/' /etc/ca-certificates.conf
update-ca-certificates -f
fi
}

# Cleanup everything at the end of the execution
cleanup() {
if test -n "$UNNEEDED_PACKAGE_LINKS"; then
Expand Down Expand Up @@ -3068,6 +3110,8 @@ if test -z "$PHP_MODULES_TO_INSTALL"; then
exit 0
fi

fixCACerts

sortModulesToInstall

docker-php-source extract
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci-test-extensions
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ testExtensionFor() {
printf ' - Docker image: %s\n' "$testExtensionFor_Image"
testExtensionFor_out="$(mktemp)"
testExtensionFor_start=$(date +%s)
if $(docker run --rm --volume "$CI_BUILD_DIR:/app" --env CI=true --workdir /app "$testExtensionFor_Image" sh -c "./install-php-extensions $1 && php ./scripts/check-installed-extension.php $1" >"$testExtensionFor_out" 2>&1); then
if $(docker run --rm --volume "$CI_BUILD_DIR:/app" --env CI=true --env IPE_FIX_CACERTS=1 --workdir /app "$testExtensionFor_Image" sh -c "./install-php-extensions $1 && php ./scripts/check-installed-extension.php $1" >"$testExtensionFor_out" 2>&1); then
testExtensionFor_end=$(date +%s)
testExtensionFor_delta=$(expr $testExtensionFor_end - $testExtensionFor_start)
rm -rf "$testExtensionFor_out"
Expand Down

0 comments on commit 73545ba

Please sign in to comment.