Hyperledger fabric client credential store using CouchDB

馋奶兔 提交于 2019-11-28 10:19:21

问题


I am using Hyperledger Fabric SDK for node.js to enroll a user. I am using this code to deploy in fabric. It uses FileKeyValueStore (uses files to store the key values) to store client's user credential.
I want to use CouchDBKeyValueStore to store user key in CouchDB database instance. What changes do i need to make in client connection profile configuration file for credential store and in code to do so. Any link to sample code will also help.


回答1:


There is no built-in support in the connection profile for using the CouchDBKeyValueStore, but you can still use the connection profile for the rest of the Fabric network configuration. You'll then need to use the Client APIs to configure the stores. Something like

const Client = require('fabric-client');
const CDBKVS = require('fabric-client/lib/impl/CouchDBKeyValueStore.js');

var client = Client.loadFromConfig('test/fixtures/network.yaml');

// Set the state store
let stateStore = await new CDBKVS({url: 'https://<USERNAME>:<PASSWORD>@<URL>', name: '<DB_NAME>'})
client.setStateStore(stateStore);

// Set the crypto store
const crypto = Client.newCryptoSuite();
let cryptoKS = Client.newCryptoKeyStore(
    CDBKVS,
    {
      url: 'https://<USERNAME>:<PASSWORD>@<URL>.cloudant.com',
      name: '<DB_NAME>'
    }
);
crypto.setCryptoKeyStore(cryptoKS);
client.setCryptoSuite(crypto);

Official document Reference
Store Hyperledger Fabric certificates and keys in IBM Cloudant with Fabric Node SDK



来源:https://stackoverflow.com/questions/54305378/hyperledger-fabric-client-credential-store-using-couchdb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!