如何在没有键值存储或钱包的情况下强制设置用户上下文?

时间:2019-06-28 01:43:03

标签: hyperledger-fabric hyperledger-fabric-ca hyperledger-fabric-sdk-java

出于测试目的,我已经准备好了公钥+私钥+证书(可以对其进行硬编码),并且可以通过连接配置文件来设置CA,但是如何在不设置证书的情况下调用事务文件系统键值存储/钱包?

1 个答案:

答案 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));

或签出integration test scripts for Fabric Node SDK