PeculiarVentures / pkcs11js

A Node.js implementation of the PKCS#11 2.40 interface
MIT License
111 stars 33 forks source link

Issue in Initialization #113

Open foryougautam opened 1 month ago

foryougautam commented 1 month ago

Issue in initialization I am testing SoftHSM2

const pkcs11js = require('pkcs11js'); try { const pkcs11 = new pkcs11js.PKCS11(); pkcs11.load('C:\SoftHSM2\lib\softhsm2-x64.dll'); pkcs11.C_Initialize(); const slots = pkcs11.C_GetSlotList(true); console.log("Available slots:", slots);

pkcs11.C_Finalize();

} catch (error) { console.error("PKCS#11 Error:", error); } Error I am getting `Pkcs11Error: CKR_GENERAL_ERROR

poc\node_modules\pkcs11js\index.js:77:22)\n' + ' at Object. (C:\Users\Gautam Bishwas\Documents\ssc2\aes-hsm-poc\test-connection.js:6:8)\n' + ' at Module._compile (node:internal/modules/cjs/loader:1358:14)\n' + ' at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)\n' + ' at Module.load (node:internal/modules/cjs/loader:1208:32)\n' + ' at Module._load (node:internal/modules/cjs/loader:1024:12)\n' + ' at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)\n' + ' at node:internal/main/run_main_module:28:49', code: 5 }`

microshine commented 1 month ago

It seems the error is coming from the provider being used. It's likely that SoftHSM is not configured properly, or the configuration file might be missing. To understand the issue, you should enable logging on the SoftHSM side and check SoftHSM logs