出于测试目的,我已经准备好了公钥+私钥+证书(可以对其进行硬编码),并且可以通过连接配置文件来设置CA,但是如何在不设置证书的情况下调用事务文件系统键值存储/钱包?
答案 0 :(得分:2)
使用InMemoryWallet
类-请参见https://fabric-sdk-node.github.io/master/module-fabric-network.InMemoryWallet.html
示例:
const credPath = '/home/demo/mynetwork/crypto-material/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp'; const cert = fs.readFileSync(credPath + '/cert.pem').toString(); const key = fs.readFileSync(credPath + '/key.pem').toString(); const inMemoryWallet = new InMemoryWallet(); await inMemoryWallet.import('admin', X509WalletMixin.createIdentity('Org1MSP', cert, key));