Skip to content

Commit ba6fdc1

Browse files
committed
fix: set openssl ca trust store for php 7.2-8.0 images
1 parent 17b9975 commit ba6fdc1

6 files changed

Lines changed: 24 additions & 1 deletion

File tree

runtime/php-72/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ RUN ${INSTALL_DIR}/bin/php /tmp/copy-dependencies.php /tmp/layer/ymir/bin /tmp/l
9797
PHP_EXT_DIR=$(${INSTALL_DIR}/bin/php-config --extension-dir) && ${INSTALL_DIR}/bin/php /tmp/copy-dependencies.php /tmp/layer/lib/php/extensions/$(basename ${PHP_EXT_DIR}) /tmp/layer/lib
9898
RUN find /tmp/layer/ymir/bin -type f -exec strip --strip-all {} + || true && find /tmp/layer/lib -type f -name "*.so*" -exec strip --strip-unneeded {} + || true && find /tmp/layer/lib -type f -name "*.a" -delete && find /tmp/layer/lib -type f -name "*.la" -delete
9999
COPY shared/php.ini /tmp/layer/ymir/etc/php/php.ini
100+
COPY shared/99-openssl-ca-legacy.ini /tmp/layer/ymir/etc/php/conf.d/99-openssl-ca-legacy.ini
100101
COPY shared/php-fpm.conf /tmp/layer/ymir/etc/php-fpm.d/php-fpm.conf
101102
RUN sed -i '/extension=msgpack.so/d' /tmp/layer/ymir/etc/php/php.ini && \
102103
sed -i 's/^decorate_workers_output = /;decorate_workers_output = /' /tmp/layer/ymir/etc/php-fpm.d/php-fpm.conf && \

runtime/php-73/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ RUN ${INSTALL_DIR}/bin/php /tmp/copy-dependencies.php /tmp/layer/ymir/bin /tmp/l
9797
PHP_EXT_DIR=$(${INSTALL_DIR}/bin/php-config --extension-dir) && ${INSTALL_DIR}/bin/php /tmp/copy-dependencies.php /tmp/layer/lib/php/extensions/$(basename ${PHP_EXT_DIR}) /tmp/layer/lib
9898
RUN find /tmp/layer/ymir/bin -type f -exec strip --strip-all {} + || true && find /tmp/layer/lib -type f -name "*.so*" -exec strip --strip-unneeded {} + || true && find /tmp/layer/lib -type f -name "*.a" -delete && find /tmp/layer/lib -type f -name "*.la" -delete
9999
COPY shared/php.ini /tmp/layer/ymir/etc/php/php.ini
100+
COPY shared/99-openssl-ca-legacy.ini /tmp/layer/ymir/etc/php/conf.d/99-openssl-ca-legacy.ini
100101
COPY shared/php-fpm.conf /tmp/layer/ymir/etc/php-fpm.d/php-fpm.conf
101102
RUN sed -i '/extension=msgpack.so/d' /tmp/layer/ymir/etc/php/php.ini
102103

runtime/php-74/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ COPY shared/copy-dependencies.php /tmp/copy-dependencies.php
9797
RUN ${INSTALL_DIR}/bin/php /tmp/copy-dependencies.php /tmp/layer/ymir/bin /tmp/layer/lib && ${INSTALL_DIR}/bin/php /tmp/copy-dependencies.php /tmp/layer/lib/php/extensions /tmp/layer/lib
9898
RUN find /tmp/layer/ymir/bin -type f -exec strip --strip-all {} + || true && find /tmp/layer/lib -type f -name "*.so*" -exec strip --strip-unneeded {} + || true && find /tmp/layer/lib -type f -name "*.a" -delete && find /tmp/layer/lib -type f -name "*.la" -delete
9999
COPY shared/php.ini /tmp/layer/ymir/etc/php/php.ini
100+
COPY shared/99-openssl-ca-legacy.ini /tmp/layer/ymir/etc/php/conf.d/99-openssl-ca-legacy.ini
100101
COPY shared/php-fpm.conf /tmp/layer/ymir/etc/php-fpm.d/php-fpm.conf
101102

102103
FROM --platform=${DOCKER_PLATFORM} public.ecr.aws/lambda/provided:al2023-${CPU_ARCHITECTURE}

runtime/php-80/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ COPY shared/copy-dependencies.php /tmp/copy-dependencies.php
9797
RUN ${INSTALL_DIR}/bin/php /tmp/copy-dependencies.php /tmp/layer/ymir/bin /tmp/layer/lib && ${INSTALL_DIR}/bin/php /tmp/copy-dependencies.php /tmp/layer/lib/php/extensions /tmp/layer/lib
9898
RUN find /tmp/layer/ymir/bin -type f -exec strip --strip-all {} + || true && find /tmp/layer/lib -type f -name "*.so*" -exec strip --strip-unneeded {} + || true && find /tmp/layer/lib -type f -name "*.a" -delete && find /tmp/layer/lib -type f -name "*.la" -delete
9999
COPY shared/php.ini /tmp/layer/ymir/etc/php/php.ini
100+
COPY shared/99-openssl-ca-legacy.ini /tmp/layer/ymir/etc/php/conf.d/99-openssl-ca-legacy.ini
100101
COPY shared/php-fpm.conf /tmp/layer/ymir/etc/php-fpm.d/php-fpm.conf
101102

102103
FROM --platform=${DOCKER_PLATFORM} public.ecr.aws/lambda/provided:al2023-${CPU_ARCHITECTURE}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
; Compatibility for legacy PHP 7.2-8.0 runtime images.
2+
; These builds can default to a custom OpenSSL CA path not present in the
3+
; final image, which breaks outbound TLS verification (HTTPS/STARTTLS).
4+
openssl.cafile=/etc/pki/tls/cert.pem
5+
openssl.capath=/etc/pki/tls/certs

runtime/test-image.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,21 @@ else
152152
echo " [OK] No PHP startup warnings"
153153
fi
154154

155-
# 8. PHP-FPM
155+
# 8. Generic TLS Crypto Validation
156+
TLS_OUTPUT=$(docker run --rm --platform "$PLATFORM" --entrypoint /opt/ymir/bin/php "$IMAGE" -r '$content=file_get_contents("https://www.google.com");if(false===$content){echo "tls_fetch_failed\n";exit(2);}echo "tls_fetch_ok\n";' 2>&1)
157+
TLS_STATUS=$?
158+
159+
if [ "$TLS_STATUS" -eq 0 ] && echo "$TLS_OUTPUT" | grep -q "tls_fetch_ok"; then
160+
echo " [OK] Outbound TLS crypto succeeded"
161+
else
162+
echo " [FAIL] Outbound TLS crypto failed"
163+
echo "--------------------------------------------------------------------------------"
164+
echo "$TLS_OUTPUT"
165+
echo "--------------------------------------------------------------------------------"
166+
FAILED=1
167+
fi
168+
169+
# 9. PHP-FPM
156170
FPM_BIN="/opt/ymir/bin/php-fpm"
157171
FPM_CONF="/opt/ymir/etc/php-fpm.d/php-fpm.conf"
158172

0 commit comments

Comments
 (0)