Skip to content

Commit

Permalink
Update tests to use OpenSSL legacy provider if OpenSSL 3.0 used
Browse files Browse the repository at this point in the history
  • Loading branch information
bukka committed Jan 29, 2025
1 parent 557b2fd commit 533ca3e
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 5 deletions.
30 changes: 28 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
10 changes: 9 additions & 1 deletion src/lib/crypto/test/cryptotest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <openssl/provider.h>
#endif
#else
#include "BotanCryptoFactory.h"
#endif
Expand Down Expand Up @@ -75,6 +78,11 @@ std::auto_ptr<BotanCryptoFactory> 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;
Expand Down
6 changes: 4 additions & 2 deletions src/lib/test/Makefile.am
Original file line number Diff line number Diff line change
@@ -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

Expand Down
12 changes: 12 additions & 0 deletions src/lib/test/p11test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,16 @@
#include <fstream>
#include <stdlib.h>
#include <iostream>
#include "config.h"
#ifdef _WIN32
#include "setenv.h"
#endif
#ifdef WITH_OPENSSL
#include <openssl/opensslv.h>
#if OPENSSL_VERSION_NUMBER >= 0x3000000fL
#include <openssl/provider.h>
#endif
#endif

class MyListener : public CPPUNIT_NS::TestListener {
virtual void startTest( CPPUNIT_NS::Test* pTest ) {
Expand All @@ -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 &registry( CPPUNIT_NS::TestFactoryRegistry::getRegistry() );

CPPUNIT_NS::TextTestRunner runner;
Expand Down

0 comments on commit 533ca3e

Please sign in to comment.