diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2015-01-11 22:41:01 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2015-01-11 22:41:01 +0100 |
commit | 8fdece38630b40aa004637c665169f19484201f3 (patch) | |
tree | 1858adf4d7621c4345bbe0d0480674db3c4b2db1 /tests | |
parent | e2b41763288626d7b7bec9c2d4076bd2312c2ff2 (diff) | |
download | gnutls-8fdece38630b40aa004637c665169f19484201f3.tar.gz |
testpkcs11: modified to support both softhsmv1 and v2
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/suite/testpkcs11.softhsm | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/tests/suite/testpkcs11.softhsm b/tests/suite/testpkcs11.softhsm index b1c783d44f..20366612a1 100755 --- a/tests/suite/testpkcs11.softhsm +++ b/tests/suite/testpkcs11.softhsm @@ -18,8 +18,6 @@ # along with GnuTLS; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -export SOFTHSM2_CONF="softhsm-testpkcs11.config" - if test -f /usr/lib64/pkcs11/libsofthsm2.so;then ADDITIONAL_PARAM="--provider /usr/lib64/pkcs11/libsofthsm2.so" else @@ -34,18 +32,34 @@ init_card () { PIN=$1 PUK=$2 - if ! test -x "/usr/bin/softhsm2-util";then - echo "Could not find /usr/bin/softhsm2-util" + if test -x "/usr/bin/softhsm2-util";then + export SOFTHSM2_CONF="softhsm-testpkcs11.config" + SOFTHSM_TOOL="/usr/bin/softhsm2-util" + fi + + if test -x "/usr/bin/softhsm";then + export SOFTHSM_CONF="softhsm-testpkcs11.config" + SOFTHSM_TOOL="/usr/bin/softhsm" + fi + + if test -z "$SOFTHSM_TOOL";then + echo "Could not find softhsm(2) tool" exit 77 fi - rm -rf ./softhsm-testpkcs11.db - mkdir -p ./softhsm-testpkcs11.db - echo "objectstore.backend = file" > $SOFTHSM2_CONF - echo "directories.tokendir = ./softhsm-testpkcs11.db" >> $SOFTHSM2_CONF + if test -z "$SOFTHSM_CONF";then + rm -rf ./softhsm-testpkcs11.db + mkdir -p ./softhsm-testpkcs11.db + echo "objectstore.backend = file" > $SOFTHSM2_CONF + echo "directories.tokendir = ./softhsm-testpkcs11.db" >> $SOFTHSM2_CONF + else + rm -rf ./softhsm-testpkcs11.db + echo "0:./softhsm-testpkcs11.db" > $SOFTHSM_CONF + fi + echo -n "* Initializing smart card... " - softhsm2-util --init-token --slot 0 --label "GnuTLS-Test" --so-pin $PUK --pin $PIN >/dev/null #2>&1 + $SOFTHSM_TOOL --init-token --slot 0 --label "GnuTLS-Test" --so-pin $PUK --pin $PIN >/dev/null #2>&1 if test $? = 0;then echo ok else |