]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
tests/pkcs11-provider: match token with --provider when initializing
authorDaiki Ueno <ueno@gnu.org>
Mon, 17 Nov 2025 23:57:43 +0000 (08:57 +0900)
committerAlexander Sosedkin <asosedkin@redhat.com>
Tue, 18 Nov 2025 15:47:05 +0000 (16:47 +0100)
Even if the "module-path" query attribute is given in the PKCS#11 URI,
p11tool does not filter tokens based on that when called with
--initialize. As this is not part of the pkcs11-provider
functionality, use --provider option to specify the token.

Also defer the settings of GNUTLS_SYSTEM_PRIORITY_FILE and
GNUTLS_SYSTEM_PRIORITY_FAIL_ON_INVALID after the token initialization.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
tests/pkcs11-provider/test-pkcs11-provider.sh

index af3b53ca59c569225a4a594856e39f9b516b933d..0ce9e51c3de0f68b7e1acffca1790ed774022065 100755 (executable)
@@ -38,11 +38,8 @@ testdir=`create_testdir pkcs11-provider`
 
 LABEL="Kryoptic Token"
 PIN="12345"
-PRIORITY_FILE="${testdir}/gnutls.conf"
 KRYOPTIC_DB="${testdir}/kryoptic.sql"
 export KRYOPTIC_CONF="${testdir}/kryoptic.conf"
-export GNUTLS_SYSTEM_PRIORITY_FAIL_ON_INVALID=1
-export GNUTLS_SYSTEM_PRIORITY_FILE="${PRIORITY_FILE}"
 export GNUTLS_DEBUG_LEVEL=6
 
 cat >"${KRYOPTIC_CONF}" <<_EOF_
@@ -58,19 +55,20 @@ _EOF_
 echo "Initializing token"
 
 # init token
-"$P11TOOL" --initialize --label "${LABEL}" --set-so-pin "${PIN}" "pkcs11:?module-path=${MODULE}" >/dev/null
+"$P11TOOL" --initialize --label "${LABEL}" --set-so-pin "${PIN}" --provider "${MODULE}" pkcs11: >/dev/null
 if test $? != 0; then
        echo "failed to initialize token"
        exit 1
 fi
 
 # set user pin
-"$P11TOOL" --initialize-pin --set-so-pin "${PIN}" --set-pin "${PIN}" "pkcs11:?module-path=${MODULE}" >/dev/null
+"$P11TOOL" --initialize-pin --set-so-pin "${PIN}" --set-pin "${PIN}" --provider "${MODULE}" pkcs11: >/dev/null
 if test $? != 0; then
        echo "failed to set user pin"
        exit 1
 fi
 
+PRIORITY_FILE="${testdir}/gnutls.conf"
 cat >"${PRIORITY_FILE}" <<_EOF_
 [overrides]
 allow-rsa-pkcs1-encrypt = true
@@ -80,6 +78,9 @@ url = pkcs11:model=v1;manufacturer=Kryoptic%20Project;token=Kryoptic%20Token
 pin = ${PIN}
 _EOF_
 
+export GNUTLS_SYSTEM_PRIORITY_FAIL_ON_INVALID=1
+export GNUTLS_SYSTEM_PRIORITY_FILE="${PRIORITY_FILE}"
+
 echo "Testing public key algorithms"
 "${builddir}/pkcs11-provider/pkcs11-provider-pk"
 rc=$?