WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit a747694

Browse files
committed
PROTON-2594: ci: setup environment for PKCS#11 test
Now that all pieces are in place, let's adapt out Github Action workflow, so softhsm2, opensc (for pkcs11-tool) and pkcs11-provider (for OpenSSL integration) are available and amend the ctest step to source scripts/prep-pkcs11_test.sh, so the relevant environment variables are exported. Note that pkcs11-provider is shipped in ubuntu-24.04, but it doesn't work, so we build it from source instead. We still need to use ubuntu-24.04, because otherwise libcrypto would be outdated: >= 3.0.7 is required, but ubuntu-latest is 22.04.5, which ships libcrypto 3.0.2.
1 parent 1fa98f4 commit a747694

File tree

3 files changed

+63
-10
lines changed

3 files changed

+63
-10
lines changed

.github/workflows/build.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
fail-fast: false
1010
matrix:
1111
os:
12-
- ubuntu-latest
12+
- ubuntu-24.04
1313
- macOS-13
1414
- windows-latest
1515
buildType:
@@ -47,7 +47,7 @@ jobs:
4747
- name: Install Linux dependencies
4848
if: runner.os == 'Linux'
4949
run: |
50-
sudo apt install -y swig libpython3-dev libsasl2-dev libjsoncpp-dev
50+
sudo apt install -y swig libpython3-dev libsasl2-dev libjsoncpp-dev softhsm2 opensc
5151
- name: Install Windows dependencies
5252
if: runner.os == 'Windows'
5353
run: |
@@ -63,6 +63,10 @@ jobs:
6363
working-directory: ${{github.workspace}}
6464
run: sudo sh ./ci/otel.sh
6565
shell: bash
66+
- name: pkcs11-provider build/install
67+
if: runner.os == 'Linux'
68+
run: sudo sh ./ci/pkcs11-provider.sh
69+
shell: bash
6670
- name: cmake configure
6771
working-directory: ${{env.BuildDir}}
6872
run: cmake "${{github.workspace}}" "-DCMAKE_BUILD_TYPE=${BuildType}" "-DCMAKE_INSTALL_PREFIX=${InstallPrefix}" ${{matrix.cmake_extra}}
@@ -88,7 +92,13 @@ jobs:
8892
- id: ctest
8993
name: ctest
9094
working-directory: ${{env.BuildDir}}
91-
run: ctest -C ${BuildType} -V -T Test --no-compress-output ${{matrix.ctest_extra}}
95+
run: |
96+
if [ "$RUNNER_OS" = "Linux" ]; then
97+
pushd ${{github.workspace}}
98+
. scripts/prep-pkcs11_test.sh
99+
popd
100+
fi
101+
ctest -C ${BuildType} -V -T Test --no-compress-output ${{matrix.ctest_extra}}
92102
shell: bash
93103
- name: Upload Test results
94104
if: always() && (steps.ctest.outcome == 'failure' || steps.ctest.outcome == 'success')

ci/pkcs11-provider.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
set -e
21+
22+
# pkcs11-provider dependencies
23+
24+
sudo apt-get install meson
25+
26+
# Clone pkcs11-provider
27+
28+
git clone -b v0.5 https://github.com/latchset/pkcs11-provider
29+
30+
# Build/Install pkcs11-provider
31+
32+
cd pkcs11-provider
33+
mkdir build
34+
35+
meson setup build .
36+
meson compile -C build
37+
meson install -C build
38+
cd ..

scripts/prep-pkcs11_test.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
# prep-pkcs11_test.sh - Source to set up environment for pkcs11_test to run
2020
# against a SoftHSM
2121

22-
KEYDIR="$(readlink -f cpp/testdata/certs)"
22+
set -x
2323

24+
KEYDIR="$(readlink -f cpp/testdata/certs)"
2425

2526
if [ -z "$PKCS11_PROVIDER" ]; then
2627
export PKCS11_PROVIDER=$(openssl version -m | cut -d'"' -f2)/pkcs11.so
@@ -53,23 +54,27 @@ sed -r "s;@softhsmtokendir@;${softhsmtokendir};g" scripts/softhsm2.conf.in >$SOF
5354

5455
export PKCS11_MODULE_LOAD_BEHAVIOR=late
5556

57+
set -x
58+
5659
softhsm2-util --delete-token --token proton-test 2>/dev/null || true
5760
softhsm2-util --init-token --free --label proton-test --pin tclientpw --so-pin tclientpw
5861

59-
alias pkcs11-tool="pkcs11-tool --module=$PKCS11_PROVIDER_MODULE --token-label proton-test --pin tclientpw"
62+
pkcs11_tool () { pkcs11-tool --module=$PKCS11_PROVIDER_MODULE --token-label proton-test --pin tclientpw "$@"; }
6063

61-
pkcs11-tool -l --label tclient --delete-object --type privkey 2>/dev/null || true
64+
pkcs11_tool --module=$PKCS11_PROVIDER_MODULE --token-label proton-test --pin tclientpw -l --label tclient --delete-object --type privkey 2>/dev/null || true
6265

63-
pkcs11-tool -l --label tclient --id 2222 \
66+
pkcs11_tool --module=$PKCS11_PROVIDER_MODULE --token-label proton-test --pin tclientpw -l --label tclient --id 2222 \
6467
--write-object "$KEYDIR/client-certificate.pem" --type cert --usage-sign
65-
pkcs11-tool -l --label tclient --id 2222 \
68+
pkcs11_tool --module=$PKCS11_PROVIDER_MODULE --token-label proton-test --pin tclientpw -l --label tclient --id 2222 \
6669
--write-object "$KEYDIR/client-private-key-no-password.pem" --type privkey --usage-sign
6770

68-
pkcs11-tool -l --label tserver --id 4444 \
71+
pkcs11_tool --module=$PKCS11_PROVIDER_MODULE --token-label proton-test --pin tclientpw -l --label tserver --id 4444 \
6972
--write-object "$KEYDIR/server-certificate-lh.pem" --type cert --usage-sign
70-
pkcs11-tool -l --label tserver --id 4444 \
73+
pkcs11_tool --module=$PKCS11_PROVIDER_MODULE --token-label proton-test --pin tclientpw -l --label tserver --id 4444 \
7174
--write-object "$KEYDIR/server-private-key-lh-no-password.pem" --type privkey --usage-sign
7275

76+
set +x
77+
7378
# Workaround for https://github.com/latchset/pkcs11-provider/issues/419
7479
export PKCS11_MODULE_LOAD_BEHAVIOR=early
7580

0 commit comments

Comments
 (0)