Skip to content

Commit e06674a

Browse files
committed
Build and run the merged-in hsm dtls_client example in CI via a dedicated hsm.yml job
1 parent 2592dbc commit e06674a

3 files changed

Lines changed: 87 additions & 0 deletions

File tree

.github/examples-manifest.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,14 @@ examples:
16451645
mode: skip
16461646
reason: "shared helper (btle-sim.c) linked by btle/ecies and btle/tls; not an example"
16471647

1648+
- id: hsm-dtls-client
1649+
path: hsm/dtls_client
1650+
mode: skip
1651+
reason: >-
1652+
Built and run end-to-end by the dedicated hsm.yml job (wolfHSM posix server +
1653+
wolfSSL DTLS server + this client, asserting the HSM-backed handshake);
1654+
master-only since wolfHSM tracks wolfSSL master
1655+
16481656
# arduino.yml does NOT cover these: it copies compile-all-examples.sh into
16491657
# $ARDUINO_ROOT/wolfssl/examples and runs it there, compiling the examples that
16501658
# ship inside the installed Arduino wolfSSL library, not this repo's sketches.

.github/workflows/hsm.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: HSM
2+
3+
on:
4+
push:
5+
paths:
6+
- 'hsm/**'
7+
- '.github/workflows/hsm.yml'
8+
pull_request:
9+
types: [opened, synchronize, reopened, ready_for_review]
10+
paths:
11+
- 'hsm/**'
12+
- '.github/workflows/hsm.yml'
13+
workflow_call:
14+
inputs:
15+
caller_run_id:
16+
description: 'run id of the calling workflow; keeps a called run in its own concurrency group'
17+
type: string
18+
default: ''
19+
workflow_dispatch:
20+
21+
concurrency:
22+
group: ${{ inputs.caller_run_id && format('hsm-call-{0}', inputs.caller_run_id) || format('hsm-{0}', github.ref) }}
23+
cancel-in-progress: ${{ !inputs.caller_run_id }}
24+
25+
permissions:
26+
contents: read
27+
28+
jobs:
29+
hsm:
30+
# wolfHSM tracks wolfSSL master, so make download_repos clones and builds both
31+
# at master; a stable-tag matrix would not build. Hence master-only.
32+
name: Run / hsm dtls_client (wolfHSM ECC over DTLS) wolfSSL master
33+
runs-on: ubuntu-24.04
34+
timeout-minutes: 30
35+
steps:
36+
- uses: actions/checkout@v5
37+
- uses: ./.github/actions/apt-update
38+
- name: Install build deps
39+
run: sudo apt-get install -y --no-install-recommends autoconf automake libtool
40+
41+
# download_repos clones wolfSSL + wolfHSM; make all builds the wolfSSL DTLS
42+
# server/client, the wolfHSM posix server, and this repo's DTLS client.
43+
- name: Clone wolfSSL + wolfHSM and build the stack
44+
working-directory: hsm/dtls_client
45+
run: |
46+
set -euo pipefail
47+
bash "$GITHUB_WORKSPACE/.github/scripts/retry.sh" make download_repos
48+
make all
49+
50+
# A successful DTLS handshake proves the client drove its ECC signing through
51+
# the HSM: wolfHSM server on TCP 23456, wolfSSL DTLS server on UDP 11111.
52+
- name: Run the wolfHSM-backed DTLS handshake
53+
working-directory: hsm/dtls_client
54+
run: |
55+
set -uo pipefail
56+
make run_hsm_server > hsm.log 2>&1 &
57+
make run_dtls_server > dtls.log 2>&1 &
58+
for _ in $(seq 1 150); do ss -tln 2>/dev/null | grep -q ':23456 ' && break; sleep 0.2; done
59+
for _ in $(seq 1 150); do ss -uln 2>/dev/null | grep -q ':11111 ' && break; sleep 0.2; done
60+
ss -tln | grep -q ':23456 ' \
61+
|| { echo "FAIL: wolfHSM server never listened on 23456"; cat hsm.log; exit 1; }
62+
ss -uln | grep -q ':11111 ' \
63+
|| { echo "FAIL: DTLS server never listened on 11111"; cat dtls.log; exit 1; }
64+
rc=0
65+
make run_client > client.log 2>&1 || rc=$?
66+
echo "--- client:"; cat client.log
67+
pkill -f wh_posix_server 2>/dev/null || true
68+
pkill -f 'examples/server/server' 2>/dev/null || true
69+
[ "$rc" -eq 0 ] \
70+
|| { echo "FAIL: client rc=$rc"; echo '--- hsm:'; cat hsm.log; echo '--- dtls:'; cat dtls.log; exit 1; }
71+
grep -q 'DTLS handshake successful' client.log \
72+
|| { echo "FAIL: no successful HSM-backed DTLS handshake"; exit 1; }
73+
echo "verified: wolfHSM-backed DTLS handshake (ECC signing on the HSM)"

.github/workflows/nightly.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ jobs:
133133
with:
134134
caller_run_id: ${{ github.run_id }}
135135

136+
hsm:
137+
needs: [refs]
138+
uses: ./.github/workflows/hsm.yml
139+
with:
140+
caller_run_id: ${{ github.run_id }}
141+
136142
device-sims:
137143
needs: [refs]
138144
uses: ./.github/workflows/device-sims.yml

0 commit comments

Comments
 (0)