Hyperledger Fabric with SoftHSM2 #fabric #hsm


Hi I have been trying to get Hyperledger Fabric (v2.0.1) to connect to SoftHSM2 (v2.5.0), but haven't been successful at that. The main purpose is to create a secret key for symmetric encryption/decryption and securely store the key inside the SoftHSM2. I plan to send unencrypted data from the Fabric smart contract to be encrypted by SoftHSM2 and send back to smart contract to be stored on blockchain ledger. Likewise, I plan to send encrypted data from blockchain to be decrypted by SoftHSM2 and unencrypted data back to smart contract then the users.

My issue is when I package my chaincode and invoke smart contract method, Fabric is not able to find the file with .so extension. In my case, the file is libsofhsm2.so. I've tested my code outside of Fabric to make sure that key generation, encryption, and decryption functions work.

Should I try to package Fabric chaincode manually into the .tar.gz file? Would that be an correct approach? I first thought that Fabric smart contract would be able to locate external file on my computer but maybe I was wrong? I have also looked into configuring Fabric to use PKCS11 but wasn't successful (https://hyperledger-fabric.readthedocs.io/en/release-2.0/dev-setup/build.html?highlight=softhsm2). I thought that this configuration is for Fabric to store user private keys in SoftHSM2 but all I want to store is a secret key which is separate from this. I don't know if this is relevant but the smart contract is written in Javascript instead of Go.

Any help or suggestion would really be appreciated. Thank you!

Join fabric@lists.hyperledger.org to automatically receive all group messages.