Skip to content

Commit 2372da7

Browse files
build: merge release/5.22.0 into main
2 parents 7af9b8c + 6dd2084 commit 2372da7

156 files changed

Lines changed: 4226 additions & 809 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# (important) exclude from GitHub Linguist language stats
2+
crate/kmip/src/**/*.html linguist-vendored
3+
crate/kmip/src/**/*.xml linguist-vendored

.github/README_WORKFLOWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ flowchart TB
415415
- **PROTECCIO_IP**: Proteccio HSM IP address
416416
- **PROTECCIO_PASSWORD**: Proteccio HSM password
417417
- **PROTECCIO_SLOT**: Proteccio HSM slot
418+
- **CRYPT2PAY_PASSWORD**: Crypt2pay HSM password
418419

419420
### Google CSE Secrets
420421

.github/scripts/docs/update_readme_kmip.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,7 @@ def generate_support_markdown(
10281028
- N/A Not applicable (operation/attribute not defined in that KMIP version)
10291029
10301030
## KMIP Baseline Profile Compliance
1031+
10311032
"""
10321033

10331034
# Add profile compliance section
@@ -1094,6 +1095,7 @@ def generate_support_markdown(
10941095
### Managed Objects
10951096
10961097
The following table shows managed object support across all KMIP versions.
1098+
10971099
"""
10981100

10991101
# Build managed objects table with version columns
@@ -1166,13 +1168,15 @@ def generate_support_markdown(
11661168
md += row + '\n'
11671169

11681170
md += """\nNotes:
1171+
11691172
- Opaque Object import support is present (see `import.rs`).
11701173
- PGP Key types appear in digest and attribute handling but full object import/register is not implemented, hence ❌.
11711174
- Template objects are deprecated in newer KMIP versions.
11721175
11731176
### Base Objects
11741177
11751178
The following table shows base object support across all KMIP versions.
1179+
11761180
"""
11771181

11781182
# Base objects list (from spec patterns); we will filter by presence in spec text per version
@@ -1391,13 +1395,15 @@ def any_impl_uses(field_name: str) -> bool:
13911395
md += row + '\n'
13921396

13931397
md += """\nNotes:
1398+
13941399
- AEAD Additional Data and Tag are supported in encrypt/decrypt APIs.
13951400
- Nonce and RNG Parameter are used by symmetric encryption paths.
13961401
- Base objects are fundamental structures present across all KMIP versions.
13971402
13981403
### Transparent Key Structures
13991404
14001405
The following table shows transparent key structure support across all KMIP versions.
1406+
14011407
"""
14021408

14031409
# Transparent key structures
@@ -1500,6 +1506,7 @@ def any_impl_uses(field_name: str) -> bool:
15001506
md += """\nNote: EC/ECDSA support is present; DH/DSA/ECMQV are not implemented.
15011507
15021508
### Attributes
1509+
15031510
"""
15041511

15051512
# Attributes table - simple 2-column format (attributes are version-agnostic)

.github/scripts/nix.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,10 @@ test_command() {
531531
SCRIPT="$REPO_ROOT/.github/scripts/test/test_hsm_proteccio.sh"
532532
shift
533533
;;
534+
crypt2pay)
535+
SCRIPT="$REPO_ROOT/.github/scripts/test/test_hsm_crypt2pay.sh"
536+
shift
537+
;;
534538
*)
535539
echo "Error: Unknown HSM backend '$HSM_BACKEND'" >&2
536540
echo "Valid backends for 'hsm': softhsm2, utimaco, proteccio, all" >&2
@@ -585,6 +589,8 @@ test_command() {
585589
--keep POSTGRES_HOST --keep POSTGRES_PORT \
586590
--keep PROTECCIO_IP --keep PROTECCIO_PASSWORD --keep PROTECCIO_SLOT \
587591
--keep PROTECCIO_PKCS11_LIB --keep PROTECCIO_PORT \
592+
--keep CRYPT2PAY_PASSWORD --keep CRYPT2PAY_SLOT_ID \
593+
--keep OVPN_CONF \
588594
--keep VARIANT \
589595
--keep TEST_GOOGLE_OAUTH_CLIENT_ID \
590596
--keep TEST_GOOGLE_OAUTH_CLIENT_SECRET \

.github/scripts/test/test_hsm.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ echo "========================================="
1212
bash "$SCRIPT_DIR/test_hsm_softhsm2.sh" "$@"
1313
bash "$SCRIPT_DIR/test_hsm_utimaco.sh" "$@"
1414
bash "$SCRIPT_DIR/test_hsm_proteccio.sh" "$@"
15+
bash "$SCRIPT_DIR/test_hsm_crypt2pay.sh" "$@"
1516

1617
echo "All HSM tests completed successfully."

.github/scripts/test/test_hsm_crypt2pay.sh

100644100755
Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,60 @@
22
set -eo pipefail
33
set -x
44

5+
# OpenVPN setup
6+
if ! command -v openvpn >/dev/null 2>&1; then
7+
echo "Installing OpenVPN..."
8+
sudo apt-get update
9+
sudo apt-get install -y openvpn
10+
fi
11+
12+
: "${OVPN_CONF:?OVPN_CONF not set}"
13+
14+
# Strip route-nopull so that server-pushed routes are accepted.
15+
# Keep pull-filter ignore "redirect-gateway" to avoid full traffic redirect.
16+
OVPN_CONF_FIXED=$(echo "$OVPN_CONF" | grep -v '^route-nopull$')
17+
echo "$OVPN_CONF_FIXED" | sudo tee /tmp/openvpn.ovpn > /dev/null
18+
19+
# Kill any previous openvpn instances to avoid duplicate routes / stale tunnels
20+
sudo killall openvpn 2>/dev/null || true
21+
sleep 1
22+
23+
# Remove stale tun0 interface to avoid "File exists" route conflicts
24+
sudo ip link del tun0 2>/dev/null || true
25+
sleep 1
26+
27+
VPN_LOG=/tmp/vpn.log
28+
sudo truncate -s 0 "$VPN_LOG" 2>/dev/null || sudo touch "$VPN_LOG"
29+
sudo chmod 644 "$VPN_LOG"
30+
31+
sudo openvpn --config /tmp/openvpn.ovpn \
32+
--log "$VPN_LOG" \
33+
--daemon
34+
35+
echo "Waiting for VPN connection..."
36+
37+
for _i in {1..30}; do
38+
if grep -q "Initialization Sequence Completed" "$VPN_LOG"; then
39+
echo "VPN connected"
40+
break
41+
fi
42+
sleep 1
43+
done
44+
45+
if ! grep -q "Initialization Sequence Completed" "$VPN_LOG"; then
46+
echo "Error: VPN not connected"
47+
cat "$VPN_LOG"
48+
exit 1
49+
fi
50+
51+
echo "VPN logs:"
52+
tail -n 50 "$VPN_LOG"
53+
554
# Crypt2pay-only tests (Linux only)
655
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
756
source "${SCRIPT_DIR}/../common.sh"
857

58+
REPO_ROOT=$(get_repo_root "$SCRIPT_DIR")
959
init_build_env "$@"
1060
setup_test_logging
1161

@@ -20,10 +70,42 @@ echo "========================================="
2070

2171
export HSM_USER_PASSWORD="${CRYPT2PAY_PASSWORD:?CRYPT2PAY_PASSWORD not set}"
2272

23-
# Note: This script assumes Crypt2pay HSM setup is already configured
24-
# Users need to set up the Crypt2pay HSM environment and related variables
73+
# Setup Crypt2pay HSM client tools
74+
if ! source "$REPO_ROOT/.github/reusable_scripts/prepare_crypt2pay.sh"; then
75+
echo "Warning: Failed to source prepare_crypt2pay.sh with return code $?."
76+
if [ -f /lib/libpkcs11c2p.so ] && [ -f /etc/c2p/c2p.xml ]; then
77+
echo "Continuing: Crypt2Pay client appears installed despite prepare script self-test failure."
78+
else
79+
echo "Error: Crypt2Pay client setup is incomplete."
80+
exit 1
81+
fi
82+
fi
83+
84+
export C2P_CONF="${C2P_CONF:-/etc/c2p/c2p.xml}"
85+
86+
# Extract the C2P HSM host and port from the config
87+
C2P_HOST=$(grep -ioP '(?<=<ip>)[^<]+' "$C2P_CONF" | head -1)
88+
C2P_PORT=$(grep -ioP '(?<=<port>)[^<]+' "$C2P_CONF" | head -1)
89+
90+
if [ -n "$C2P_HOST" ] && [ -n "$C2P_PORT" ]; then
91+
echo "Checking HSM connectivity at $C2P_HOST:$C2P_PORT ..."
92+
HSM_REACHABLE=false
93+
for _i in {1..30}; do
94+
if timeout 3 bash -c "echo >/dev/tcp/$C2P_HOST/$C2P_PORT" 2>/dev/null; then
95+
echo "HSM service is reachable"
96+
HSM_REACHABLE=true
97+
break
98+
fi
99+
echo " retry $_i/30 - waiting 2s..."
100+
sleep 2
101+
done
102+
if [ "$HSM_REACHABLE" = false ]; then
103+
echo "Error: HSM service $C2P_HOST:$C2P_PORT is not reachable over the VPN"
104+
exit 1
105+
fi
106+
fi
25107

26-
# CRYPT2PAY integration test (KMS)
108+
# CRYPT2PAY integration test (KMS server)
27109
env \
28110
PATH="$PATH" \
29111
HSM_MODEL="crypt2pay" \
@@ -34,6 +116,7 @@ env \
34116
${FEATURES_FLAG[@]+"${FEATURES_FLAG[@]}"} \
35117
-- tests::hsm::test_hsm_all --ignored --exact
36118

119+
# CRYPT2PAY PKCS#11 loader test
37120
env \
38121
PATH="$PATH" \
39122
HSM_MODEL="crypt2pay" \

.github/scripts/test/test_hsm_proteccio.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ set -x
3535
# Setup Proteccio HSM client tools
3636
if ! source "$REPO_ROOT/.github/reusable_scripts/prepare_proteccio.sh"; then
3737
echo "Warning: Failed to source prepare_proteccio.sh, nethsmstatus may be failing. with return code $?."
38-
exit 1
38+
exit 0
3939
fi
4040

4141
# PROTECCIO integration test (KMS)

.github/scripts/test/test_hsm_softhsm2.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,27 @@ env \
6868

6969
echo "SoftHSM2 KMS server tests completed successfully."
7070

71+
# Run KMIP 1.2 TTLV integration test for issue #933 (non-fips only, as the
72+
# ttlv_tests module is gated behind #[cfg(feature = "non-fips")]).
73+
if [[ " ${FEATURES_FLAG[*]:-} " == *"non-fips"* ]]; then
74+
echo "========================================="
75+
echo "Running issue #933 KMIP 1.2 protocol test (SoftHSM2)"
76+
echo "========================================="
77+
env \
78+
PATH="$PATH" \
79+
LD_LIBRARY_PATH="${SOFTHSM2_LIB_DIR:+$SOFTHSM2_LIB_DIR:}${NIX_OPENSSL_OUT:+$NIX_OPENSSL_OUT/lib:}${LD_LIBRARY_PATH:-}" \
80+
DYLD_LIBRARY_PATH="${SOFTHSM2_LIB_DIR:+$SOFTHSM2_LIB_DIR:}${NIX_OPENSSL_OUT:+$NIX_OPENSSL_OUT/lib:}${DYLD_LIBRARY_PATH:-}" \
81+
SOFTHSM2_PKCS11_LIB="${SOFTHSM2_PKCS11_LIB_PATH:-}" \
82+
HSM_MODEL="softhsm2" \
83+
HSM_USER_PASSWORD="$HSM_USER_PASSWORD" \
84+
HSM_SLOT_ID="$SOFTHSM2_HSM_SLOT_ID" \
85+
cargo test \
86+
-p cosmian_kms_server \
87+
${FEATURES_FLAG[@]+"${FEATURES_FLAG[@]}"} \
88+
-- tests::ttlv_tests::integrations::synology_dsm::test_issue_933_modify_attribute_kmip12_payload --ignored --exact
89+
echo "Issue #933 KMIP 1.2 test passed."
90+
fi
91+
7192
env \
7293
PATH="$PATH" \
7394
LD_LIBRARY_PATH="${SOFTHSM2_LIB_DIR:+$SOFTHSM2_LIB_DIR:}${NIX_OPENSSL_OUT:+$NIX_OPENSSL_OUT/lib:}${LD_LIBRARY_PATH:-}" \

.github/scripts/test/test_otel_export.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ port = ${KMS_HTTP_PORT}
484484
[logging]
485485
enable_metering = true
486486
otlp = "${OTEL_EXPORT_OTLP_ENDPOINT}"
487+
otlp_allow_insecure = true
487488
488489
[db]
489490
database_type = "sqlite"

0 commit comments

Comments
 (0)