Skip to content

Commit 533ca3e

Browse files
committed
Update tests to use OpenSSL legacy provider if OpenSSL 3.0 used
1 parent 557b2fd commit 533ca3e

File tree

4 files changed

+53
-5
lines changed

4 files changed

+53
-5
lines changed

.github/workflows/ci.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ on:
88
pull_request:
99

1010
jobs:
11-
linux:
11+
linux_ubuntu_20:
1212
name: Linux (${{ matrix.backend }})
13-
runs-on: ubuntu-20.04 # for OpenSSL 1.1.1
13+
runs-on: ubuntu-20.04 # for OpenSSL 1.1.1 and Botan 2.12
1414
strategy:
1515
fail-fast: false
1616
matrix:
@@ -34,6 +34,32 @@ jobs:
3434
run: |
3535
make check || (find . -name test-suite.log -exec cat {} \; && false)
3636
37+
linux_ubuntu_24:
38+
name: Linux (${{ matrix.backend }})
39+
runs-on: ubuntu-24.04 # for OpenSSL 3.0 and Botan 2.19
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
include:
44+
- backend: openssl
45+
- backend: botan
46+
steps:
47+
- uses: actions/checkout@v4
48+
- name: Prepare
49+
run: |
50+
sudo apt update -qq
51+
sudo apt install libcppunit-dev libbotan-2-dev p11-kit
52+
- name: Build
53+
env:
54+
CXXFLAGS: -DBOTAN_NO_DEPRECATED_WARNINGS
55+
run: |
56+
./autogen.sh
57+
./configure --with-crypto-backend=${{ matrix.backend }}
58+
make
59+
- name: Test
60+
run: |
61+
make check || (find . -name test-suite.log -exec cat {} \; && false)
62+
3763
macos:
3864
name: macOS (${{ matrix.backend }})
3965
runs-on: macos-14

src/lib/crypto/test/cryptotest.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@
4444
#include "MutexFactory.h"
4545
#include "SecureMemoryRegistry.h"
4646

47-
#if defined(WITH_OPENSSL)
47+
#ifdef WITH_OPENSSL
4848
#include "OSSLCryptoFactory.h"
49+
#if OPENSSL_VERSION_NUMBER >= 0x3000000fL
50+
#include <openssl/provider.h>
51+
#endif
4952
#else
5053
#include "BotanCryptoFactory.h"
5154
#endif
@@ -75,6 +78,11 @@ std::auto_ptr<BotanCryptoFactory> BotanCryptoFactory::instance(NULL);
7578

7679
int main(int /*argc*/, char** /*argv*/)
7780
{
81+
#if defined(WITH_OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x3000000fL
82+
OSSL_PROVIDER_load(NULL, "legacy");
83+
OSSL_PROVIDER_load(NULL, "default");
84+
#endif
85+
7886
CppUnit::TestResult controller;
7987
CppUnit::TestResultCollector result;
8088
CppUnit::TextUi::TestRunner runner;

src/lib/test/Makefile.am

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
22

3-
AM_CPPFLAGS = -I$(srcdir)/.. \
3+
AM_CPPFLAGS = -I$(srcdir)/../.. \
4+
-I$(srcdir)/.. \
45
-I$(srcdir)/../common \
56
-I$(srcdir)/../pkcs11 \
6-
@CPPUNIT_CFLAGS@
7+
@CPPUNIT_CFLAGS@ \
8+
@CRYPTO_INCLUDES@
79

810
check_PROGRAMS = p11test
911

src/lib/test/p11test.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,16 @@
4545
#include <fstream>
4646
#include <stdlib.h>
4747
#include <iostream>
48+
#include "config.h"
4849
#ifdef _WIN32
4950
#include "setenv.h"
5051
#endif
52+
#ifdef WITH_OPENSSL
53+
#include <openssl/opensslv.h>
54+
#if OPENSSL_VERSION_NUMBER >= 0x3000000fL
55+
#include <openssl/provider.h>
56+
#endif
57+
#endif
5158

5259
class MyListener : public CPPUNIT_NS::TestListener {
5360
virtual void startTest( CPPUNIT_NS::Test* pTest ) {
@@ -71,6 +78,11 @@ int main(int /*argc*/, char**const /*argv*/)
7178
#endif
7279
#endif
7380

81+
#if defined(WITH_OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x3000000fL
82+
OSSL_PROVIDER_load(NULL, "legacy");
83+
OSSL_PROVIDER_load(NULL, "default");
84+
#endif
85+
7486
CPPUNIT_NS::TestFactoryRegistry &registry( CPPUNIT_NS::TestFactoryRegistry::getRegistry() );
7587

7688
CPPUNIT_NS::TextTestRunner runner;

0 commit comments

Comments
 (0)