cryptogen generate --config=./crypto-config.yaml
configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID ${CHANNEL_NAME}
// 组织Org1的锚节点 configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID ${CHANNEL_NAME} -asOrg Org1MSP // 组织Org2的锚节点 configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID ${CHANNEL_NAME} -asOrg Org2MSP
peer channel create -o orderer.example.com:7050 -c ${CHANNEL_NAME} -f ./channel-artifacts/channel.tx --tls ${CORE_PEER_TLS_ENABLED} --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
cli错误提示: Error: got unexpected status: FORBIDDEN -- Failed to reach implicit threshold of 1 sub-policies, required 1 remaining: permission denied 容器内部提示: UTC [cauthdsl] deduplicate -> ERRO 014 Principal deserialization failure (the supplied identity is not valid: x509: certificate signed by unknown authority (possibly because of "x509: ECDSA verification failure" while trying to verify candidate authority certificate "ca.org1.example.com")) for identity
错误缘由:因为启动过网络而且更新了证书,在没有删除干净的环境中启动复用的以前的volume,因此致使证书认证失败。git
解决方案:github
$ docker-compose -f docker-compose-cli.yaml -f docker-compose-couch.yaml down --volumes Stopping cli ... done Stopping peer1.org2.example.com ... done Stopping peer0.org2.example.com ... done Stopping orderer.example.com ... done Stopping peer0.org1.example.com ... done Stopping peer1.org1.example.com ... done Removing cli ... done Removing peer1.org2.example.com ... done Removing peer0.org2.example.com ... done Removing orderer.example.com ... done Removing peer0.org1.example.com ... done Removing peer1.org1.example.com ... done Removing network net_byfn Removing volume net_peer0.org2.example.com Removing volume net_peer1.org2.example.com Removing volume net_peer1.org1.example.com Removing volume net_peer0.org1.example.com Removing volume net_orderer.example.com
peer channel join -b mychannel.block
peer channel list
peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
docker exec peer0.org1.example.com ls /var/hyperledger/production/chaincodes
peer chaincode instantiate -o orderer.example.com:7050 --tls ${CORE_PEER_TLS_ENABLED} --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n mycc -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "OR('Org1MSP.member','Org2MSP.member')"
peer chaincode query -C $CHANNEL_NAME -nmycc -c '{"Args":["query","a"]}' peer chaincode query -C $CHANNEL_NAME -nmycc -c '{"Args":["query","b"]}'
peer chaincode invoke -oorderer.example.com:7050 --tls ${CORE_PEER_TLS_ENABLED}--cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C ${CHANNEL_NAME} -n mycc -c'{"Args":["invoke","a","b","10"]}'