Skip to content

Commit 797c936

Browse files
Use OpenSSL 3.2 across all PHP versions
1 parent 4ce0a7f commit 797c936

File tree

6 files changed

+24
-6
lines changed

6 files changed

+24
-6
lines changed

layers/openssl3.patch

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Patch for OpenSSL 3 support for PHP 8.0
2+
--- a/ext/openssl/openssl.c
3+
+++ b/ext/openssl/openssl.c
4+
@@ -1325,7 +1325,9 @@
5+
REGISTER_LONG_CONSTANT("OPENSSL_CMS_NOSIGS", CMS_NOSIGS, CONST_CS|CONST_PERSISTENT);
6+
7+
REGISTER_LONG_CONSTANT("OPENSSL_PKCS1_PADDING", RSA_PKCS1_PADDING, CONST_CS|CONST_PERSISTENT);
8+
+#ifdef RSA_SSLV23_PADDING
9+
REGISTER_LONG_CONSTANT("OPENSSL_SSLV23_PADDING", RSA_SSLV23_PADDING, CONST_CS|CONST_PERSISTENT);
10+
+#endif
11+
REGISTER_LONG_CONSTANT("OPENSSL_NO_PADDING", RSA_NO_PADDING, CONST_CS|CONST_PERSISTENT);
12+
REGISTER_LONG_CONSTANT("OPENSSL_PKCS1_OAEP_PADDING", RSA_PKCS1_OAEP_PADDING, CONST_CS|CONST_PERSISTENT);
13+

php-80/Dockerfile

+7-2
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,14 @@ RUN set -xe; \
103103
# Needed by:
104104
# - curl
105105
# - php
106-
ENV VERSION_OPENSSL=1.1.1w
106+
RUN yum install -y perl-IPC-Cmd
107+
ENV VERSION_OPENSSL=3.2.0
107108
ENV OPENSSL_BUILD_DIR=${BUILD_DIR}/openssl
108109
ENV CA_BUNDLE_SOURCE="https://curl.se/ca/cacert.pem"
109110
ENV CA_BUNDLE="${INSTALL_DIR}/bref/ssl/cert.pem"
110111
RUN set -xe; \
111112
mkdir -p ${OPENSSL_BUILD_DIR}; \
112-
curl -Ls https://github.com/openssl/openssl/archive/OpenSSL_${VERSION_OPENSSL//./_}.tar.gz \
113+
curl -Ls https://github.com/openssl/openssl/releases/download/openssl-${VERSION_OPENSSL}/openssl-${VERSION_OPENSSL}.tar.gz \
113114
| tar xzC ${OPENSSL_BUILD_DIR} --strip-components=1
114115
WORKDIR ${OPENSSL_BUILD_DIR}/
115116
RUN CFLAGS="" \
@@ -384,6 +385,10 @@ ARG VERSION_PHP
384385
RUN curl --location --silent --show-error --fail https://www.php.net/get/php-${VERSION_PHP}.tar.gz/from/this/mirror \
385386
| tar xzC . --strip-components=1
386387

388+
COPY layers/openssl3.patch ${PHP_BUILD_DIR}
389+
RUN patch -N -p1 -s < openssl3.patch
390+
RUN rm openssl3.patch
391+
387392
# Configure the build
388393
# -fstack-protector-strong : Be paranoid about stack overflows
389394
# -fpic : Make PHP's main executable position-independent (improves ASLR security mechanism, and has no performance impact on x86_64)

php-81/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ RUN set -xe; \
104104
# - curl
105105
# - php
106106
RUN yum install -y perl-IPC-Cmd
107-
ENV VERSION_OPENSSL=3.0.12
107+
ENV VERSION_OPENSSL=3.2.0
108108
ENV OPENSSL_BUILD_DIR=${BUILD_DIR}/openssl
109109
ENV CA_BUNDLE_SOURCE="https://curl.se/ca/cacert.pem"
110110
ENV CA_BUNDLE="${INSTALL_DIR}/bref/ssl/cert.pem"

php-82/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ RUN set -xe; \
104104
# - curl
105105
# - php
106106
RUN yum install -y perl-IPC-Cmd
107-
ENV VERSION_OPENSSL=3.0.12
107+
ENV VERSION_OPENSSL=3.2.0
108108
ENV OPENSSL_BUILD_DIR=${BUILD_DIR}/openssl
109109
ENV CA_BUNDLE_SOURCE="https://curl.se/ca/cacert.pem"
110110
ENV CA_BUNDLE="${INSTALL_DIR}/bref/ssl/cert.pem"

php-83/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ RUN set -xe; \
104104
# - curl
105105
# - php
106106
RUN yum install -y perl-IPC-Cmd
107-
ENV VERSION_OPENSSL=3.0.12
107+
ENV VERSION_OPENSSL=3.2.0
108108
ENV OPENSSL_BUILD_DIR=${BUILD_DIR}/openssl
109109
ENV CA_BUNDLE_SOURCE="https://curl.se/ca/cacert.pem"
110110
ENV CA_BUNDLE="${INSTALL_DIR}/bref/ssl/cert.pem"

tests/test_2_extensions.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
// https://github.com/brefphp/aws-lambda-layers/issues/42
8282
'curl-http2' => defined('CURL_HTTP_VERSION_2'),
8383
// Make sure we are not using the default AL2 OpenSSL version (7.79)
84-
'curl-openssl' => str_starts_with(curl_version()['ssl_version'], 'OpenSSL/1.1.1') || str_starts_with(curl_version()['ssl_version'], 'OpenSSL/3.0'),
84+
'curl-openssl' => str_starts_with(curl_version()['ssl_version'], 'OpenSSL/3.2'),
8585
// Check that the default certificate file exists
8686
// https://github.com/brefphp/aws-lambda-layers/issues/53
8787
'curl-openssl-certificates' => file_exists(openssl_get_cert_locations()['default_cert_file']),

0 commit comments

Comments
 (0)