I'm trying to generate a public/private keypair in softHSM, for this I have installed a provider in openssl.
Using these commands I end up in a "user error"
+ softhsm2-util --init-token --free --label token-label --so-pin mysopin1 --pin mysecret1
Slot 0 has a free/uninitialized token.
The token has been initialized and is reassigned to slot 251791662
++ p11tool --list-token-urls
++ grep token-label
+ export 'TOKEN=pkcs11:model=SoftHSM%20v2;manufacturer=SoftHSM%20project;serial=95c88c090f02092e;token=token-label'
+ TOKEN='pkcs11:model=SoftHSM%20v2;manufacturer=SoftHSM%20project;serial=95c88c090f02092e;token=token-label'
+ p11tool --set-so-pin=mysopin1 --initialize 'pkcs11:model=SoftHSM%20v2;manufacturer=SoftHSM%20project;serial=95c88c090f02092e;token=token-label' --label token-label
Initializing token... done
Token was successfully initialized; use --initialize-pin and --initialize-so-pin to set or reset PINs
+ p11tool --login --set-so-pin=mysopin1 --generate-privkey=Ed25519 --bits 1024 --set-pin=mysecret1 --outfile MyNewKey.pub 'pkcs11:model=SoftHSM%20v2;manufacturer=SoftHSM%20project;serial=95c88c090f02092e;token=token-label' --label token-label
Generating an EdDSA (Ed25519) key...
Error in pkcs11_generate:1355: PKCS #11 user error
I have searched up a number of examples of using p11tool and they all say this is the way to run the commands, and Generating an EdDSA (Ed25519) key...
indicates that something works.
This also puzzles me, but adding --initialize-pin and --initialize-so-pin
does not help.
Token was successfully initialized; use --initialize-pin and --initialize-so-pin to set or reset PINs
This is how I install the tools with a Dockerfile
FROM ubuntu:22.04
USER root
RUN apt update
RUN apt install -y opensc git build-essential automake libtool libengine-pkcs11-openssl libp11-kit-dev libp11-dev gnutls-bin libcppunit-dev libssl-dev softhsm
COPY openssl.cnf /etc/ssl/openssl.cnf
RUN openssl engine pkcs11 -t
The full example with a Dockerfile can be seen here: https://gitlab.com/kjeld.flarup/softhsmdemo