Skip to content

Commit 75cf872

Browse files
author
“sahmad154”
committed
Fix PKCS#11 infrastructure issues
- Fix slot detection: Use grep -B 20 to find slot number before label Resolves CKR_TOKEN_NOT_RECOGNIZED errors with dynamic slot assignment - Add PKCS#11 engine symlink: Create link from ENGINESDIR to actual engine location Enables OpenSSL to find pkcs11.so engine for curl --engine pkcs11 - Fix client CA chain copy: Add existence check before copying Prevents silent failures when ICA chain file missing Tested in running container: - Certificate import successful with 3 objects (rdkclient, rdkclient-key, rdkclient-p12-key) - OpenSSL engine available: openssl engine -t pkcs11 returns [available] - L2 tests pass: 54 passed, 30 skipped
1 parent 39612af commit 75cf872

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

native-platform/certs.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ if [ "$ENABLE_MTLS" = "true" ]; then
103103

104104
# Copy client CA chain to shared volume for mock-xconf container
105105
mkdir -p "$SHARED_CERTS_DIR/client"
106-
cp "$CLIENT_ICA_CHAIN" "$SHARED_CERTS_DIR/client/ca-chain.pem"
106+
if [ -f "$CLIENT_ICA_CHAIN" ]; then
107+
cp "$CLIENT_ICA_CHAIN" "$SHARED_CERTS_DIR/client/ca-chain.pem"
108+
else
109+
echo "[certs] WARNING: Client ICA chain not found at $CLIENT_ICA_CHAIN" >&2
110+
fi
107111

108112
# Validate shared export exists and is non-empty
109113
if [ ! -s "$SHARED_CERTS_DIR/client/ca-chain.pem" ]; then

native-platform/scripts/import-certs-to-pkcs11.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ if [ ! -f "$PKCS11_MODULE" ]; then
1919
exit 1
2020
fi
2121

22-
# Get token slot
23-
SLOT=$(softhsm2-util --show-slots | grep -A 2 "$TOKEN_LABEL" | grep "Slot " | awk '{print $2}')
22+
# Get token slot by searching for the label and extracting the slot number before it
23+
SLOT=$(softhsm2-util --show-slots | grep -B 20 "Label:.*$TOKEN_LABEL" | grep "^Slot " | head -1 | awk '{print $2}')
2424
if [ -z "$SLOT" ]; then
2525
echo "[import-certs-to-pkcs11] ERROR: Token '$TOKEN_LABEL' not found"
2626
exit 1

native-platform/scripts/setup-pkcs11-openssl.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ fi
8989
echo "/usr/local/lib64" > /etc/ld.so.conf.d/openssl-local.conf
9090
ldconfig
9191

92+
# Create symlink for PKCS#11 engine (OpenSSL looks in ENGINESDIR=/usr/local/lib64/engines-3)
93+
echo "[setup-pkcs11-openssl] Creating PKCS#11 engine symlink..."
94+
mkdir -p /usr/local/lib64/engines-3
95+
ln -sf /usr/lib/x86_64-linux-gnu/engines-3/pkcs11.so /usr/local/lib64/engines-3/pkcs11.so
96+
9297
# Verify installation
9398
FINAL_VERSION=$(${INSTALL_PREFIX}/bin/openssl version 2>/dev/null | awk '{print $2}')
9499
if [ "$FINAL_VERSION" = "$OPENSSL_VERSION" ]; then

0 commit comments

Comments
 (0)