适用于多组织的HyperLedger Fabric的CA,注册,注册。

时间:2018-12-13 04:57:18

标签: hyperledger-fabric hyperledger hyperledger-fabric-ca

我正在尝试使用每个组织的3个Org和3个CA服务器建立多通道网络,并且每个组织中只有一个对等方,并且有两个通道,第一个位于Org1 --- Org2之间,第二个位于在Org1 --- Org3之间。我在通过节点sdk进行注册时遇到问题。我只是为每个组织注册了1个管理员并用其MSP ID注册了1个用户..但是对于org1,我只能做到这一点,而对于其他组织,则可以给它error.Please任何人都可以在那里分享有关该知识的信息,实际上我在做错事。

https://github.com/hyperledger/fabric-samples/tree/release-1.3/fabcar

诸如enrollAdmin.js和registerUser.js之类的东西 我在尝试..

version: '2'

networks:
      basic:

services:
  ca.org1.example.com:
   image: hyperledger/fabric-ca
   environment:
  - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
  - FABRIC_CA_SERVER_CA_NAME=ca.org1.example.com
  - FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem
  - FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/ee2d84ed07a905e1da7e37720d8ab19e10955a7de00c37f80ee5003da2fe71fb_sk
ports:
  - "7054:7054"
command: sh -c 'fabric-ca-server start -b admin:adminpw -d'
volumes:
  - ./crypto-config/peerOrganizations/org1.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
container_name: ca.org1.example.com
networks:
  - basic

ca.org2.example.com:
image: hyperledger/fabric-ca
environment:
  - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
  - FABRIC_CA_SERVER_CA_NAME=ca.org2.example.com
  - FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem
  - FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/8672a5680bfc1549c80a2bd51ebf5f9377963842bc69c953beff22b5fa7fd4a1_sk
ports:
  - "8054:7054"
command: sh -c 'fabric-ca-server start -b admin:adminpw -d'
volumes:
  - ./crypto-config/peerOrganizations/org2.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
container_name: ca.org2.example.com
networks:
  - basic

ca.org3.example.com:
image: hyperledger/fabric-ca
environment:
  - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
  - FABRIC_CA_SERVER_CA_NAME=ca.org3.example.com
  - FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org3.example.com-cert.pem
  - FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/7fae57bfc762f669eed6f05a6dbe1d1284366a7cf23e2060c38501360c90405c_sk
ports:
  - "9054:7054"
command: sh -c 'fabric-ca-server start -b admin:adminpw -d'
volumes:
  - ./crypto-config/peerOrganizations/org3.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
container_name: ca.org3.example.com
networks:
  - basic


orderer.example.com:
container_name: orderer.example.com
image: hyperledger/fabric-orderer
environment:
  - ORDERER_GENERAL_LOGLEVEL=debug
  - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
  - ORDERER_GENERAL_GENESISMETHOD=file
  - ORDERER_GENERAL_GENESISFILE=/etc/hyperledger/configtx/genesis.block
  - ORDERER_GENERAL_LOCALMSPID=OrdererMSP
  - ORDERER_GENERAL_LOCALMSPDIR=/etc/hyperledger/msp/orderer/msp
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderer
command: orderer
ports:
  - 7050:7050
volumes:
    - ./config/:/etc/hyperledger/configtx
    - ./crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/:/etc/hyperledger/msp/orderer
    - ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/:/etc/hyperledger/msp/peerOrg1
    - ./crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/:/etc/hyperledger/msp/peerOrg2
    - ./crypto-config/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/:/etc/hyperledger/msp/peerOrg3
networks:
  - basic

peer0.org1.example.com:
container_name: peer0.org1.example.com
image: hyperledger/fabric-peer
environment:
  - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
  - CORE_PEER_ID=peer0.org1.example.com
  - CORE_LOGGING_PEER=debug
  - CORE_CHAINCODE_LOGGING_LEVEL=DEBUG
  - CORE_PEER_LOCALMSPID=Org1MSP
  - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
  - CORE_PEER_ADDRESS=peer0.org1.example.com:7051
  # # the following setting starts chaincode containers on the same
  # # bridge network as the peers
  # # https://docs.docker.com/compose/networking/
  - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_basic
  - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
  - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
  # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
  # provide the credentials for ledger to connect to CouchDB.  The username and password must
  # match the username and password set for the associated CouchDB.
  - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
  - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start
# command: peer node start --peer-chaincodedev=true
ports:
  - 7051:7051
  - 7053:7053
volumes:
    - /var/run/:/host/var/run/
    - ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/msp/peer
    - ./crypto-config/peerOrganizations/org1.example.com/users:/etc/hyperledger/msp/users
    - ./config:/etc/hyperledger/configtx
depends_on:
  - orderer.example.com
  - couchdb
networks:
  - basic

peer0.org2.example.com:
container_name: peer0.org2.example.com
image: hyperledger/fabric-peer
environment:
  - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
  - CORE_PEER_ID=peer0.org2.example.com
  - CORE_LOGGING_PEER=debug
  - CORE_CHAINCODE_LOGGING_LEVEL=DEBUG
  - CORE_PEER_LOCALMSPID=Org2MSP
  - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
  - CORE_PEER_ADDRESS=peer0.org2.example.com:7051
  # # the following setting starts chaincode containers on the same
  # # bridge network as the peers
  # # https://docs.docker.com/compose/networking/
  - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_basic
  - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
  - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
  # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
  # provide the credentials for ledger to connect to CouchDB.  The username and password must
  # match the username and password set for the associated CouchDB.
  - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
  - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start
# command: peer node start --peer-chaincodedev=true
ports:
  - 8051:7051
  - 8053:7053
volumes:
    - /var/run/:/host/var/run/
    - ./crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/msp/peer
    - ./crypto-config/peerOrganizations/org2.example.com/users:/etc/hyperledger/msp/users
    - ./config:/etc/hyperledger/configtx
depends_on:
  - orderer.example.com
  - couchdb
networks:
  - basic

peer0.org3.example.com:
container_name: peer0.org3.example.com
image: hyperledger/fabric-peer
environment:
  - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
  - CORE_PEER_ID=peer0.org3.example.com
  - CORE_LOGGING_PEER=debug
  - CORE_CHAINCODE_LOGGING_LEVEL=DEBUG
  - CORE_PEER_LOCALMSPID=Org3MSP
  - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
  - CORE_PEER_ADDRESS=peer0.org3.example.com:7051
  # # the following setting starts chaincode containers on the same
  # # bridge network as the peers
  # # https://docs.docker.com/compose/networking/
  - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_basic
  - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
  - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
  # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
  # provide the credentials for ledger to connect to CouchDB.  The username and password must
  # match the username and password set for the associated CouchDB.
  - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
  - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start
# command: peer node start --peer-chaincodedev=true
ports:
  - 9051:7051
  - 9053:7053
volumes:
    - /var/run/:/host/var/run/
    - ./crypto-config/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp:/etc/hyperledger/msp/peer
    - ./crypto-config/peerOrganizations/org3.example.com/users:/etc/hyperledger/msp/users
    - ./config:/etc/hyperledger/configtx
depends_on:
  - orderer.example.com
  - couchdb
networks:
  - basic


couchdb:
container_name: couchdb
image: hyperledger/fabric-couchdb
# Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
# for CouchDB.  This will prevent CouchDB from operating in an "Admin Party" mode.
environment:
  - COUCHDB_USER=
  - COUCHDB_PASSWORD=
ports:
  - 5984:5984
networks:
  - basic


cli:
container_name: cli
image: hyperledger/fabric-tools
tty: true
environment:
  - GOPATH=/opt/gopath
  - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
  - CORE_LOGGING_LEVEL=DEBUG
  - CORE_PEER_ID=cli
  - CORE_PEER_ADDRESS=peer0.org1.example.com:7051
  - CORE_PEER_LOCALMSPID=Org1MSP
  - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
  - CORE_CHAINCODE_KEEPALIVE=10
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: /bin/bash
volumes:
    - /var/run/:/host/var/run/
    - ./../chaincode/:/opt/gopath/src/github.com/
    - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
    - ./config:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifaexample
networks:
    - basic

#depends_on:
#  - orderer.example.com
#  - peer0.org1.example.com
#  - peer0.org2.example.com
#  - peer0.org3.example.com
#  - couchdb

1 个答案:

答案 0 :(得分:1)

我认为,您对概念有误解。

实际上,NodeSDK是客户端的一部分,一次一个客户端应用程序可以代表一个组织。

但是;如果要为每个组织创建用户,则需要确保使用每个组织的不同输入参数将请求发送到每个不同的CA。