-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtest.sh
executable file
·66 lines (50 loc) · 1.82 KB
/
runtest.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
set -e
export PKCS11_PROVIDER=$(find $PWD/build/out -wholename */ossl-modules/pkcs11.so)
export PKCS11_PROVIDER_MODULE="/usr/lib/softhsm/libsofthsm2.so"
if [ ! -r "$PKCS11_PROVIDER" ]; then
echo "PKCS11_PROVIDER $PKCS11_PROVIDER not found"
exit 1
fi
if [ ! -r "$PKCS11_PROVIDER_MODULE" ]; then
echo "PKCS11_PROVIDER_MODUKE $PKCS11_PROVIDER_MODULE not found"
exit 1
fi
export SOFTHSM2_CONF=$PWD/softhsm2.conf
export OPENSSL_CONF=$PWD/openssl-pkcs11.cnf
export PKCS11_MODULE_LOAD_BEHAVIOR=late
echo
echo "Running test without PKCS#11"
echo "============================"
cd build/out/share/proton/tests
./connect_config_test
echo
echo "Loading Keys into SoftHSM"
echo "========================="
cd testdata/certs
mkdir -p /tmp/softhsm-tokens-pkcs11-provider-qpid-proton-bug-reproduction
softhsm2-util --delete-token --token test 2>/dev/null || true
softhsm2-util --init-token --free --label test --pin tclientpw --so-pin tclientpw
alias pkcs11-tool="pkcs11-tool --module=$PKCS11_PROVIDER_MODULE --token-label test --pin tclientpw"
pkcs11-tool -l --label tclient --delete-object --type privkey 2>/dev/null || true
pkcs11-tool -l --label tclient --id 4444 \
--write-object client-private-key-no-password.pem --type privkey --usage-sign
cd ../..
obj="pkcs11:token=test;id=%44%44;object=tclient"
# crashes for me when it's loaded early...
openssl storeutl -provider pkcs11 -keys -out pkcs11-key.pem "$obj"
echo
echo "Running test _with_ PKCS#11"
echo "==========================="
export PKCS11_MODULE_LOAD_BEHAVIOR=${LOAD_BEHAVIOR:-late}
export TEST_KEY=pkcs11-key.pem
# cat $TEST_KEY
if ./connect_config_test; then
echo "==========================="
echo SUCCESS!
echo "==========================="
else
echo "==========================="
echo FAILURE! Now try again with LOAD_BEHAVIOR=early
echo "==========================="
fi