【问题标题】:Failed to deserialize creater identity , the supplied identity is not valid error in Hyperledger无法反序列化创建者身份,提供的身份在 Hyperledger 中是无效的错误
【发布时间】:2018-03-11 19:52:15
【问题描述】:

我一直在尝试继续使用 SDK 从已安装的链代码中调用函数,但我遇到了一个问题,我正在努力解决这个问题。 我构建的 javascript 程序是 test/integration/client.js 文件和 fabcar/invoke.js 的混合体。但是,当我运行脚本时,在运行事务提议时出现以下错误:

错误:[client-utils.js]:sendPeersProposal - Promise 被拒绝:错误:无法反序列化创建者身份,err 提供的身份无效,Verify() 返回 x509:证书由未知机构签名

我知道我的问题是由于没有使用正确的证书,但我不知道我在哪里没有使用正确的证书。我使用以下脚本创建了 crypto-config 目录:

 ../src/github.com/hyperledger/fabric/build//bin/cryptogen 生成 --config=./crypto-config.yaml
../src/github.com/hyperledger/fabric/build//bin/configtxgen --profile OrdererGenesis -outputBlock ./channel-artifacts/genesis.block
../src/github.com/hyperledger/fabric/build//bin/configtxgen --profile Channel --outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
../src/github.com/hyperledger/fabric/build//bin/configtxgen --profile Channel -outputAnchorPeersUpdate ./channel-artifacts/CorpMSPanchors.tx -channelID $CHANNEL_NAME -asOrg CorpMSP
../src/github.com/hyperledger/fabric/build//bin/configtxgen --profile Channel -outputAnchorPeersUpdate ./channel-artifacts/EngMSPanchors.tx -channelID $CHANNEL_NAME -asOrg EngMSP

这是我添加我的同伴和我的频道的代码:

让数据 = fs.readFileSync(network[org].peers['peer1']['tls_cacerts']); var peer = client.newPeer( 网络[org].peers['peer1'].requests, { pem: Buffer.from(data).toString(), 'ssl-target-name-override':网络[org].peers['peer1']['server-hostname'] }); console.log("- 对端建立,建立通道"); 频道 = client.newChannel(utils.getConfigSetting('channelName')); 通道.addPeer(peer); 数据 = fs.readFileSync(network.orderer['tls_cacerts']); channel.addOrderer(client.newOrderer(network.orderer['url']), { pem: Buffer.from(data).toString(), 'ssl-target-name-override':network.orderer['server-hostname'] }); 目标.push(peer);

这是我的网络配置:

{ "tmpdir": "/tmp/hfc_test_kvs", "channelName" : "我的频道", "chaincodeId" : "blockparty", “网络配置”:{ “订购者”:{ "url": "grpcs://orderer.example.com:7050", “服务器主机名”:“orderer.example.com”, “tls_cacerts”:“./crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem” }, “组织1”:{ “名称”:“公司”, "mspid": "CorpMSP", “用户名”:“管理员”, “同行”:{ “同行1”:{ “请求”:“grpcs://peer0.corp.example.com:7051”, "事件": "grpcs://peer0.corp.example.com:7053", “服务器主机名”:“peer0.corp.example.com”, “tls_cacerts”:“./crypto-config/peerOrganizations/corp.example.com/peers/peer0.corp.example.com/tls/server.crt” }, “行政”: { “密钥”:“./crypto-config/peerOrganizations/corp.example.com/users/Admin@corp.example.com/msp/keystore”, “证书”:“./crypto-config/peerOrganizations/corp.example.com/users/Admin@corp.example.com/msp/signcerts” } },

根据要求,这是我的 crypto-config.yaml 的一些 sn-ps:

订购者组织: - 名称:订购者 域名:example.com 眼镜: - 主机名:订购者 对等组织: - 名称:公司 域:corp.example.com 眼镜: - 主机名:peer0 - 主机名:peer1 - 主机名:peer2 用户: 计数:1

还有我的 configtx.yaml:

Profiles:

    OrdererGenesis:
        Orderer:
            <<: *OrdererDefaults
            Organizations:
                - *OrdererOrg
        Consortiums:
            SampleConsortium:
                Organizations:
                    - *Corp
                    - *Eng
    Channel:
        Consortium: SampleConsortium
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Corp
                - *Eng

################################################################################
#
#   Section: Organizations
#
#   - This section defines the different organizational identities which will
#   be referenced later in the configuration.
#
################################################################################
Organizations:

    # SampleOrg defines an MSP using the sampleconfig.  It should never be used
    # in production but may be used as a template for other definitions
    - &OrdererOrg
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: OrdererOrg

        # ID to load the MSP definition as
        ID: OrdererMSP

        # MSPDir is the filesystem path which contains the MSP configuration
        MSPDir: crypto-config/ordererOrganizations/example.com/msp

    - &Corp
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: CorpMSP

        # ID to load the MSP definition as
        ID: CorpMSP

        MSPDir: crypto-config/peerOrganizations/corp.example.com/msp

        AnchorPeers:
            # AnchorPeers defines the location of peers which can be used
            # for cross org gossip communication.  Note, this value is only
            # encoded in the genesis block in the Application section context
            - Host: peer0.corp.example.com
              Port: 7051

对于我应该使用哪个证书来正确提交交易提案和交易有什么想法吗?我没有使用 ca-server,也没有使用 docker 容器。环境工作,因为我能够使用peer chaincode invoke 命令调用链代码,所以我知道它工作,但我不确定我应该在client.newPeerclient.newChannel 函数中使用哪个证书。

非常感谢您的阅读, 伯特兰。

【问题讨论】:

  • 你能发布crypto-config.yaml和configtx.yaml的sn-ps吗?
  • 完成。添加了请求的代码 sn-ps。 :)
  • 您是否有意省略了Eng组织的定义?
  • 另外,我对你的最后一句话感到困惑:“环境工作,因为我能够使用对等链码调用命令调用链码,所以我知道它有效,但我不确定我应该在 client.newPeer 和 client.newChannel 函数中使用哪个证书。”你能调用吗?或者你调用并得到错误作为响应?
  • @ArtemBarger:是的,我故意省略了Eng 组织的定义,因为它与Corp 组织相同。通过调用,我的意思是我可以运行peer chaincode invoke 命令,它正确执行给我正确的结果。

标签: hyperledger-fabric hyperledger


【解决方案1】:

我认为您需要客户端管理员的证书。最好由 corp.example.com 或 peer#.corp.example.com 签名。 corp.example.com 的证书链已经存在于您的 MSPDir/ca 文件夹中。所以这应该可以解决问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-07
    • 1970-01-01
    • 1970-01-01
    • 2020-04-20
    • 2021-09-12
    • 2021-08-30
    相关资源
    最近更新 更多