Skip to content

Commit 87424fb

Browse files
committed
Update tests to use OpenSSL legacy provider if OpenSSL 3.0 used
Also add pipeline to test OpenSSL 3.0
1 parent 76c7ed8 commit 87424fb

File tree

4 files changed

+70
-14
lines changed

4 files changed

+70
-14
lines changed

.github/workflows/ci.yml

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,35 @@ on:
88
pull_request:
99

1010
jobs:
11-
linux:
12-
name: Linux (${{ matrix.backend }})
11+
linux_botan:
12+
name: Linux with Botan
1313
runs-on: ubuntu-24.04
14-
strategy:
15-
fail-fast: false
16-
matrix:
17-
include:
18-
- backend: openssl
19-
- backend: botan
2014
steps:
2115
- uses: actions/checkout@v4
2216
- name: Prepare
2317
run: |
24-
sudo apt update -qq
25-
sudo apt install libcppunit-dev libbotan-2-dev p11-kit
18+
sudo apt-get update -qq
19+
sudo apt-get install -y libcppunit-dev libbotan-2-dev p11-kit
20+
- name: Build
21+
env:
22+
CXXFLAGS: -Werror -DBOTAN_NO_DEPRECATED_WARNINGS
23+
run: |
24+
./autogen.sh
25+
./configure --with-crypto-backend=botan
26+
make
27+
- name: Test
28+
run: |
29+
make check || (find . -name test-suite.log -exec cat {} \; && false)
30+
31+
linux_ossl_1:
32+
name: Linux with OpenSSL 1.1.1
33+
runs-on: ubuntu-24.04
34+
steps:
35+
- uses: actions/checkout@v4
36+
- name: Prepare
37+
run: |
38+
sudo apt-get update -qq
39+
sudo apt-get install -y libcppunit-dev p11-kit
2640
# Replace installed OpenSSL with the supported version 1.1.1
2741
curl -O http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.24_amd64.deb
2842
curl -O http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl-dev_1.1.1f-1ubuntu2.24_amd64.deb
@@ -32,10 +46,31 @@ jobs:
3246
libssl-dev_1.1.1f-1ubuntu2.24_amd64.deb
3347
- name: Build
3448
env:
35-
CXXFLAGS: -Werror -DBOTAN_NO_DEPRECATED_WARNINGS
49+
CXXFLAGS: -Werror
50+
run: |
51+
./autogen.sh
52+
./configure --with-crypto-backend=openssl
53+
make
54+
- name: Test
55+
run: |
56+
make check || (find . -name test-suite.log -exec cat {} \; && false)
57+
58+
linux_ossl_30:
59+
name: Linux with OpenSSL 3.0
60+
runs-on: ubuntu-24.04
61+
steps:
62+
- uses: actions/checkout@v4
63+
- name: Prepare
64+
run: |
65+
sudo apt-get update -qq
66+
sudo apt-get install -y libcppunit-dev libssl-dev p11-kit
67+
- name: Build
68+
# Once all OpenSSL deprecations fixed, uncomment this
69+
# env:
70+
# CXXFLAGS: -Werror
3671
run: |
3772
./autogen.sh
38-
./configure --with-crypto-backend=${{ matrix.backend }}
73+
./configure --with-crypto-backend=openssl
3974
make
4075
- name: Test
4176
run: |

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 >= 0x30000000L
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 >= 0x30000000L
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
33
AM_CPPFLAGS = -I$(srcdir)/.. \
44
-I$(srcdir)/../common \
55
-I$(srcdir)/../pkcs11 \
6-
@CPPUNIT_CFLAGS@
6+
@CPPUNIT_CFLAGS@ \
7+
@CRYPTO_INCLUDES@
78

89
check_PROGRAMS = p11test
910

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 >= 0x30000000L
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 >= 0x30000000L
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)