diff --git a/.github/actions/install/libressl/action.yml b/.github/actions/install/libressl/action.yml index 709ad70..7e5b190 100644 --- a/.github/actions/install/libressl/action.yml +++ b/.github/actions/install/libressl/action.yml @@ -4,7 +4,7 @@ inputs: version: description: The desired LibreSSL version to install required: false - default: "3.3.0" + default: "4.2.1" runs: using: composite steps: diff --git a/.github/workflows/ssl.yml b/.github/workflows/ssl.yml index 7f7a954..f412a26 100644 --- a/.github/workflows/ssl.yml +++ b/.github/workflows/ssl.yml @@ -55,14 +55,14 @@ jobs: run: cmake --preset unit-tests -DOPENSSL_ROOT_DIR=/tmp -DCMAKE_CXX_FLAGS="-DOPENSSL_NO_DEPRECATED=1" -DCMAKE_C_FLAGS="-DOPENSSL_NO_DEPRECATED=1" - run: cmake --build --preset unit-tests - name: test - run: ctest --preset unit-tests + run: ctest --preset unit-tests --output-on-failure libressl: runs-on: ubuntu-latest strategy: fail-fast: false matrix: - libressl: ["3.5.3", "3.4.3", "3.3.6"] + libressl: ["4.2.1", "4.1.2", "3.9.2"] name: LibreSSL ${{ matrix.libressl }} steps: - uses: actions/checkout@v4 @@ -76,7 +76,7 @@ jobs: run: cmake --preset unit-tests -DJWT_SSL_LIBRARY:STRING=LibreSSL - run: cmake --build --preset unit-tests - name: test - run: ctest --preset unit-tests + run: ctest --preset unit-tests --output-on-failure - if: github.event_name == 'push' && always() uses: ./.github/actions/badge @@ -106,7 +106,7 @@ jobs: run: cmake --preset unit-tests -DJWT_SSL_LIBRARY:STRING=wolfSSL - run: cmake --build --preset unit-tests - name: test - run: ctest --preset unit-tests + run: ctest --preset unit-tests --output-on-failure - if: github.event_name == 'push' && always() uses: ./.github/actions/badge diff --git a/.gitignore b/.gitignore index a594c29..8c2dfa7 100644 --- a/.gitignore +++ b/.gitignore @@ -318,3 +318,4 @@ build/* package-lock.json CMakeUserPresets.json +cmake/FindLibreSSL.cmake diff --git a/docs/ssl.md b/docs/ssl.md index 50db2ba..83287a0 100644 --- a/docs/ssl.md +++ b/docs/ssl.md @@ -18,9 +18,9 @@ These are the versions which are currently being tested: | OpenSSL | LibreSSL | wolfSSL | | ----------------- | -------------- | -------------- | -| ![3.0.19][o3.0] | ![3.3.6][l3.3] | ![5.1.1][w5.1] | -| ![3.5.5][o3.5] :star: | ![3.4.3][l3.4] | ![5.2.0][w5.2] | -| ![3.6.1][o3.6] | ![3.5.3][l3.5] | ![5.3.0][w5.3] | +| ![3.0.19][o3.0] | ![4.2.1][l4.2] | ![5.1.1][w5.1] | +| ![3.5.5][o3.5] :star: | ![4.1.2][l4.1] | ![5.2.0][w5.2] | +| ![3.6.1][o3.6] | ![3.9.2][l3.9] | ![5.3.0][w5.3] | > [!NOTE] > :star: Indicates LTS (Long-Term Support) versions. [OpenSSL versions](https://openssl-library.org/policies/releasestrat/index.html) are supported as follows: @@ -36,9 +36,9 @@ These are the versions which are currently being tested: [o3.0]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/openssl/3.0.19/shields.json [o3.5]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/openssl/3.5.5/shields.json [o3.6]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/openssl/3.6.1/shields.json -[l3.3]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/libressl/3.3.6/shields.json -[l3.4]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/libressl/3.4.3/shields.json -[l3.5]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/libressl/3.5.3/shields.json +[l4.2]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/libressl/4.2.1/shields.json +[l4.1]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/libressl/4.1.2/shields.json +[l3.9]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/libressl/3.9.2/shields.json [w5.1]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/wolfssl/5.1.1/shields.json [w5.2]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/wolfssl/5.2.0/shields.json [w5.3]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/wolfssl/5.3.0/shields.json diff --git a/tests/CMakePresets.json b/tests/CMakePresets.json index ee1af5b..3655039 100644 --- a/tests/CMakePresets.json +++ b/tests/CMakePresets.json @@ -37,6 +37,30 @@ "JWT_BUILD_TESTS": "ON" } }, + { + "name": "mac-libressl", + "inherits": ["unit-tests"], + "displayName": "macOS Unit Tests (LibreSSL)", + "description": "This is only available on macOS and requires LibreSSL to be installed via Homebrew. You can install it with `brew install libressl`. You need to manually download the FindLibreSSL.cmake file from the LibreSSL repository and place it in the cmake/ directory of this project.", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Darwin" + }, + "cacheVariables": { + "JWT_SSL_LIBRARY": "LibreSSL", + "LIBRESSL_ROOT_DIR": "$env{HOMEBREW_PREFIX}/opt/libressl" + } + }, + { + "name": "linux-libressl", + "inherits": ["linux", "unit-tests"], + "displayName": "Linux Unit Tests (LibreSSL)", + "description": "This is only available on Linux and requires LibreSSL to be installed. You need to manually download the FindLibreSSL.cmake file from the LibreSSL repository and place it in the cmake/ directory of this project.", + "cacheVariables": { + "JWT_SSL_LIBRARY": "LibreSSL" + } + }, { "name": "ci-fuzzing", "inherits": ["debug", "linux"], @@ -103,6 +127,22 @@ "jwt-cpp-test" ] }, + { + "name": "mac-libressl", + "configurePreset": "mac-libressl", + "configuration": "Debug", + "targets": [ + "jwt-cpp-test" + ] + }, + { + "name": "linux-libressl", + "configurePreset": "linux-libressl", + "configuration": "Debug", + "targets": [ + "jwt-cpp-test" + ] + }, { "name": "ci-fuzzing", "configurePreset": "ci-fuzzing", diff --git a/tests/OpenSSLErrorTest.cpp b/tests/OpenSSLErrorTest.cpp index 71440b3..ee3d0b9 100644 --- a/tests/OpenSSLErrorTest.cpp +++ b/tests/OpenSSLErrorTest.cpp @@ -330,6 +330,20 @@ int EC_KEY_check_key(const EC_KEY* key) { return origMethod(key); } +#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x4020000fL +// LibreSSL 4.2.0+ changed EVP_PKEY_get1_EC_KEY to take const EVP_PKEY* +EC_KEY* EVP_PKEY_get1_EC_KEY(const EVP_PKEY* pkey) { + static EC_KEY* (*origMethod)(const EVP_PKEY* pkey) = nullptr; + if (origMethod == nullptr) origMethod = (decltype(origMethod))dlsym(RTLD_NEXT, SYMBOL_NAME("EVP_PKEY_get1_EC_KEY")); + bool fail = fail_EVP_PKEY_get1_EC_KEY & 1; + fail_EVP_PKEY_get1_EC_KEY = fail_EVP_PKEY_get1_EC_KEY >> 1; + if (fail) + return nullptr; + else + return origMethod(pkey); +} +#else +// LibreSSL < 4.2.0 uses non-const EVP_PKEY* EC_KEY* EVP_PKEY_get1_EC_KEY(EVP_PKEY* pkey) { static EC_KEY* (*origMethod)(EVP_PKEY * pkey) = nullptr; if (origMethod == nullptr) origMethod = (decltype(origMethod))dlsym(RTLD_NEXT, SYMBOL_NAME("EVP_PKEY_get1_EC_KEY")); @@ -341,6 +355,7 @@ EC_KEY* EVP_PKEY_get1_EC_KEY(EVP_PKEY* pkey) { return origMethod(pkey); } #endif +#endif ECDSA_SIG* ECDSA_SIG_new(void) { static ECDSA_SIG* (*origMethod)() = nullptr;