KeyManager service error: pkcs11.wrapper.PKCS11Exception: CKR_GENERAL_ERROR

We have built the keymanager using docker file and we have tried to start it but we are getting the following error:
. pkcs11.wrapper.PKCS11Exception: CKR_GENERAL_ERROR

Please note that we have also updated the file that contains the hsm conf , it has been copied from softHsm to artifactory.

Below the stack error:

Error creating bean with name ‘keymanagerServiceImpl’: Unsatisf’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'keykernel-keymanager-service.jar!/BOOT-INF/classes!/io/mosip/kernel/keymanager/hsm/impl/KeyStoreImpl.class]: Invocativa.lang.reflect.InvocationTargetException\n\tat\n\tat org.springframework.beans.factory.annotation.InjectionMetadata.igframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(\n\tat orgutowireCapableBeanFactory.createBean(\n\tat org.springframework.beans.Bean$0(\n\tat\n\tat\n\stractBeanFactory.getBean(\n\tat org.springframework.beans.factory.config.DependencyDjava:251)\n\tat\n.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(\springframework.beans.factory.BeanCreationException: Error creating bean with name ‘keyStoreImpl’ defined in URL [ar!/BOOT-INF/classes!/io/mosip/kernel/keymanager/hsm/impl/KeyStoreImpl.class]: Invocation of init method failed; nargetException\n\tat$doGetBean$0(\n\tat\n\tat\n\tat org.springframeworkveCandidate(\n\tat\n\tat$AutowiredFieldElement.inject(AutowiredAnnotn frames omitted\nCaused by: java.lang.reflect.InvocationTargetException: null\n\tat java.base/jdk.internal.reflecive Method)\n\tat java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccesslect.DelegatingConstructorAccessorImpl.newInstance(\n\tat java.base/\n\tat io.mosip.kernel.keymanager.hsm.impl.KeyStoreImpl.afterPropertiesSet(\n\tatactAutowireCapableBeanFactory.invokeInitMethods(\n\tat org.springframbleBeanFactory.initializeBean(\n\t… 50 common frames omitted\nCauseNoSuchSecurityProviderException: KER-KMA-001 → Config file invalid; \nnested exception is\n\tat io.mosip.kerneitKeystore(\n\tat io.mosip.kernel.keymanager.hsm.impl.pkcs.PKCS11KeyStoreImpl.(Pmes omitted\nCaused by: Initialization failed\n\tat jdk.crypto.cryptoki/sun.securn\tat jdk.crypto.cryptoki/$\n\tat jdk.crypto.cryptoki/\n\tat java.base/ Method)\n\tat jdk.crypto.cryptoki/sun.securit\n\tat io.mosip.kernel.keymanager.hsm.impl.pkcs.PKCS11KeyStoreImpl.setupProvider(\n\t.rity.pkcs11.wrapper.PKCS11Exception: CKR_GENERAL_ERROR\n\tat jdk.crypto.cryptoki/$SynchronizedPKCS11.C_Initialize(\n\tat jdk.crypto.crypnce(\n\tat jdk.crypto.cryptoki/\n\t… 64 nager-service"

Are you using softhsm or a commercial HSM?

I’am using sofHsm of mosip.
Please note that I have tested the below command and it worked perfectly:
pkcs11-tool --module /usr/local/lib/ -l -k --key-type rsa:2048 --id 4142 --label tokenKey1 --pin 1111
This command has been executed inside the softhsm conatiner.
below its output:

Using slot 0 with a present token (0x68df9638)
Key pair generated:
Private Key Object; RSA
label: tokenKey1
ID: 4142
Usage: decrypt, sign, unwrap
Public Key Object; RSA 2048 bits
label: tokenKey1
ID: 4142
Usage: encrypt, verify, wrap

Hi Zeddari,

softHSM docker configuration looks fine. MOSIP keymanager container uses “pcks11 proxy” as client to softHSM. This PKCS11 proxy communicates with softHSM through tcp connection and this proxy client expects an environment variable in keymanager container. Can you please confirm whether the environment variable added in keymanager docker.

Here is environment variable name:

Here is full value

thank you for your replay.
we should add it in the docker run command:
docker run --add-host config-server:xxx --add-host postgres:xx–add-host artifactory-service:xx -d -e iam_adapter_url=‘’ -e db.dbuser.password=‘xxxxx’ -e PKCS11_DAEMON_SOCKET=‘tcp://xxxxx:5666’ -e PKCS11_PROXY_SOCKET=‘tcp://xx:5666’

Are you not using Kubernetes? Any specific reason?

We get the same error when we deploy the keymanager in kubernetes and we add variables in Dockerfile.

Hi Slimab,

Can you check whether “PKCS11_PROXY_SOCKET” environment variable is added or not.

we need to add only the PROXY_SOCKET variable and “PKCS11_DAEMON_SOCKET” variable should be available in kernel-softhsm docker.

Please recheck the same. Share full keyamanger service logs if getting same error.

Hello mahammedtaheer,
Do you mean that the PROXY_SOCKET should be available in Keymanager, and the PKCS11_DAEMON_SOCKET is added only in kernel-softhsm docker or in both (Keymanager, kernel-softhsm docker)!!!


Hi slimab,

Add PKCS11_DAEMON_SOCKET=tcp:// in kernel-softhsm
and add PKCS11_PROXY_SOCKET=‘tcp://kernel-softhms:5666’ in keymanager service.


hello @mahammedtaheer
it’s a variable environment of keymanager

softhsm-kernel.softhsm is the service name and 5666 is the port

it’s a variable environment of softhsm

But always the same error appears :

Hi Slimab,

Please check there is port redirect happening in the cluster. The PKCS11_PROXY_SOCKET value should be “PKCS11_PROXY_SOCKET=tcp://softhsm-kernel.softhsm:80”. please change the port to 80 and try.

Also can you please share full logs of keymanager service.