From 533ca3e78b7fb6101b2ba4104a65b8f06aae2007 Mon Sep 17 00:00:00 2001 From: Jakub Zelenka Date: Tue, 28 Jan 2025 16:13:42 +0100 Subject: [PATCH] Update tests to use OpenSSL legacy provider if OpenSSL 3.0 used --- .github/workflows/ci.yml | 30 ++++++++++++++++++++++++++++-- src/lib/crypto/test/cryptotest.cpp | 10 +++++++++- src/lib/test/Makefile.am | 6 ++++-- src/lib/test/p11test.cpp | 12 ++++++++++++ 4 files changed, 53 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ae7fb8a4d..e6ae3cc1c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,9 +8,9 @@ on: pull_request: jobs: - linux: + linux_ubuntu_20: name: Linux (${{ matrix.backend }}) - runs-on: ubuntu-20.04 # for OpenSSL 1.1.1 + runs-on: ubuntu-20.04 # for OpenSSL 1.1.1 and Botan 2.12 strategy: fail-fast: false matrix: @@ -34,6 +34,32 @@ jobs: run: | make check || (find . -name test-suite.log -exec cat {} \; && false) + linux_ubuntu_24: + name: Linux (${{ matrix.backend }}) + runs-on: ubuntu-24.04 # for OpenSSL 3.0 and Botan 2.19 + strategy: + fail-fast: false + matrix: + include: + - backend: openssl + - backend: botan + steps: + - uses: actions/checkout@v4 + - name: Prepare + run: | + sudo apt update -qq + sudo apt install libcppunit-dev libbotan-2-dev p11-kit + - name: Build + env: + CXXFLAGS: -DBOTAN_NO_DEPRECATED_WARNINGS + run: | + ./autogen.sh + ./configure --with-crypto-backend=${{ matrix.backend }} + make + - name: Test + run: | + make check || (find . -name test-suite.log -exec cat {} \; && false) + macos: name: macOS (${{ matrix.backend }}) runs-on: macos-14 diff --git a/src/lib/crypto/test/cryptotest.cpp b/src/lib/crypto/test/cryptotest.cpp index d9dc72e0e..5a4e000a5 100644 --- a/src/lib/crypto/test/cryptotest.cpp +++ b/src/lib/crypto/test/cryptotest.cpp @@ -44,8 +44,11 @@ #include "MutexFactory.h" #include "SecureMemoryRegistry.h" -#if defined(WITH_OPENSSL) +#ifdef WITH_OPENSSL #include "OSSLCryptoFactory.h" +#if OPENSSL_VERSION_NUMBER >= 0x3000000fL +#include +#endif #else #include "BotanCryptoFactory.h" #endif @@ -75,6 +78,11 @@ std::auto_ptr BotanCryptoFactory::instance(NULL); int main(int /*argc*/, char** /*argv*/) { +#if defined(WITH_OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x3000000fL + OSSL_PROVIDER_load(NULL, "legacy"); + OSSL_PROVIDER_load(NULL, "default"); +#endif + CppUnit::TestResult controller; CppUnit::TestResultCollector result; CppUnit::TextUi::TestRunner runner; diff --git a/src/lib/test/Makefile.am b/src/lib/test/Makefile.am index a22ce6684..50d507c8e 100644 --- a/src/lib/test/Makefile.am +++ b/src/lib/test/Makefile.am @@ -1,9 +1,11 @@ MAINTAINERCLEANFILES = $(srcdir)/Makefile.in -AM_CPPFLAGS = -I$(srcdir)/.. \ +AM_CPPFLAGS = -I$(srcdir)/../.. \ + -I$(srcdir)/.. \ -I$(srcdir)/../common \ -I$(srcdir)/../pkcs11 \ - @CPPUNIT_CFLAGS@ + @CPPUNIT_CFLAGS@ \ + @CRYPTO_INCLUDES@ check_PROGRAMS = p11test diff --git a/src/lib/test/p11test.cpp b/src/lib/test/p11test.cpp index bf9fb1f60..7af3d4d3f 100644 --- a/src/lib/test/p11test.cpp +++ b/src/lib/test/p11test.cpp @@ -45,9 +45,16 @@ #include #include #include +#include "config.h" #ifdef _WIN32 #include "setenv.h" #endif +#ifdef WITH_OPENSSL +#include +#if OPENSSL_VERSION_NUMBER >= 0x3000000fL +#include +#endif +#endif class MyListener : public CPPUNIT_NS::TestListener { virtual void startTest( CPPUNIT_NS::Test* pTest ) { @@ -71,6 +78,11 @@ int main(int /*argc*/, char**const /*argv*/) #endif #endif +#if defined(WITH_OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x3000000fL + OSSL_PROVIDER_load(NULL, "legacy"); + OSSL_PROVIDER_load(NULL, "default"); +#endif + CPPUNIT_NS::TestFactoryRegistry ®istry( CPPUNIT_NS::TestFactoryRegistry::getRegistry() ); CPPUNIT_NS::TextTestRunner runner;