From b2a4041cc0dc43654d2bfb860281a0f733bf6e1a Mon Sep 17 00:00:00 2001 From: filipe oliveira Date: Mon, 8 Apr 2024 15:02:11 +0100 Subject: [PATCH] Fixed build for tls v1.3 on openssl v1.0.2. Added CI check (#253) * fixed build for tls v1.3 on openssl v1.0.2. Added CI check * fixed ci step name * Include test for openssl v3.0 * Make reference to openssl@3.0 on the Readme given its the LTS version --- .github/workflows/ci.yml | 18 ++++++++++++++++-- README.md | 4 ++-- memtier_benchmark.cpp | 3 +++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a58a443..8c27ba44 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -101,6 +101,18 @@ jobs: bash <(curl -s https://codecov.io/bash) -f memtier_benchmark-*-coverage.info || echo "Codecov did not collect coverage reports" build-macos: + strategy: + matrix: + openssl: ["1.1", "3.0"] + runs-on: macos-latest + steps: + - uses: actions/checkout@v1 + - name: Install dependencies + run: brew install autoconf automake libtool libevent pkg-config openssl@${{ matrix.openssl }} + - name: Build + run: autoreconf -ivf && PKG_CONFIG_PATH=/usr/local/opt/openssl@${{ matrix.openssl }}/lib/pkgconfig ./configure && make + + build-macos-openssl-1-0-2: strategy: matrix: platform: [macos-latest] @@ -108,6 +120,8 @@ jobs: steps: - uses: actions/checkout@v1 - name: Install dependencies - run: brew install autoconf automake libtool libevent pkg-config openssl@1.1 + run: brew install autoconf automake libtool libevent pkg-config + - name: Install openssl v1.0.2 + run: brew install rbenv/tap/openssl@1.0 - name: Build - run: autoreconf -ivf && PKG_CONFIG_PATH=/usr/local/opt/openssl@1.1/lib/pkgconfig ./configure && make + run: autoreconf -ivf && PKG_CONFIG_PATH=/usr/local/opt/openssl@1.0/lib/pkgconfig ./configure && make diff --git a/README.md b/README.md index 80c2f3dd..4b51d8c0 100644 --- a/README.md +++ b/README.md @@ -84,14 +84,14 @@ On Ubuntu/Debian distributions, simply install all prerequisites as follows: To build natively on macOS, use Homebrew to install the required dependencies: ``` -$ brew install autoconf automake libtool libevent pkg-config openssl@1.1 +$ brew install autoconf automake libtool libevent pkg-config openssl@3.0 ``` When running `./configure`, if it fails to find libssl it may be necessary to tweak the `PKG_CONFIG_PATH` environment variable: ``` -PKG_CONFIG_PATH=/usr/local/opt/openssl@1.1/lib/pkgconfig ./configure +PKG_CONFIG_PATH=/usr/local/opt/openssl@3.0/lib/pkgconfig ./configure ``` ### Building and installing diff --git a/memtier_benchmark.cpp b/memtier_benchmark.cpp index 61f560a2..2314da88 100755 --- a/memtier_benchmark.cpp +++ b/memtier_benchmark.cpp @@ -1392,8 +1392,11 @@ int main(int argc, char *argv[]) SSL_CTX_set_options(cfg.openssl_ctx, SSL_OP_NO_TLSv1_1); if (!(cfg.tls_protocols & REDIS_TLS_PROTO_TLSv1_2)) SSL_CTX_set_options(cfg.openssl_ctx, SSL_OP_NO_TLSv1_2); +// TLS 1.3 is only available as from version 1.1.1. +#if OPENSSL_VERSION_NUMBER >= 0x10101000L if (!(cfg.tls_protocols & REDIS_TLS_PROTO_TLSv1_3)) SSL_CTX_set_options(cfg.openssl_ctx, SSL_OP_NO_TLSv1_3); +#endif if (cfg.tls_cert) { if (!SSL_CTX_use_certificate_chain_file(cfg.openssl_ctx, cfg.tls_cert)) {