【问题标题】:When trying to join a peer to a channel, "this policy requires 1 of the 'Readers' sub-policies to be satisfied: permission denied" error occurs尝试将对等方加入频道时,出现“此策略需要满足 'Readers' 子策略之一:权限被拒绝”错误
【发布时间】:2020-08-21 20:15:52
【问题描述】:

我正在尝试 Fabric v2.2,但由于某些政策问题(我猜),一直未能加入对等通道。为了获得 orderer 和 peer 的 MSP,我使用了 orderer 组织和 peer 组织的 CA(有一个 peer 组织)。

fabric-ca-client register -d --id.name ${PEERS[$i]} --id.secret ${PEER_ADMIN_PWS[$i]} --id.type peer -u https://$CA_NODE:7054
…
fabric-ca-client register -d --id.name $ORG_ADMIN_ID --id.secret $ORG_ADMIN_PW --id.type admin -u https://$CA_NODE:7054
….
fabric-ca-client register -d --id.name ${ORDERERS[$i]} --id.secret ${ORDERER_ADMIN_PWS[$i]} --id.type orderer -u https://$CA_NODE:7054

…
fabric-ca-client enroll -d -u https://${NODES[$i]}:${NODE_ADMIN_PWS[$i]}@$CA_NODE:7054

我认为 MSP 没问题,因为网络运行良好。

然后,我启动了一个 CLI 容器并创建了一个名为 identitych 的频道。我认为它工作得很好,因为我检查了identitych 目录已在所有订购者的chains 目录下创建。

之后,当我提出使用以下命令将节点加入通道时,由于权限被拒绝,orderer 无法向 peer 交付块,并且由于 FORBIDDEN,peer 无法从 orderer 中检索块问题。

peer channel join -b /channel-artifacts/identitych.block

我的configtx.yaml 文件如下所示:

Organizations:
  - &BPLOrdererOrg
    Name: BPLOrdererMSP
    ID: BPLOrdererMSP
    MSPDir: ./orderers/org-msp

    Policies:
      Readers:
        Type: Signature
        Rule: "OR('BPLOrdererMSP.member')"
      Writers:
        Type: Signature
        Rule: "OR('BPLOrdererMSP.member')"
      Admins:
        Type: Signature
        Rule: "OR('BPLOrdererMSP.admin')"

    OrdererEndpoints:
      - orderer0.common.bpl:7050

  - &BPLOrg
    Name: BPLMSP
    ID: BPLMSP
    MSPDir: ./peers/org-msp

    Policies:
      Readers:
        Type: Signature
        Rule: "OR('BPLMSP.admin', 'BPLMSP.peer', 'BPLMSP.client')"
      Writers:
        Type: Signature
        Rule: "OR('BPLMSP.admin', 'BPLMSP.client')"
      Admins:
        Type: Signature
        Rule: "OR('BPLMSP.admin')"
      Endorsement:
        Type: Signature
        Rule: "OR('BPLMSP.peer')"

NodeOUs 是通过将config.yaml 放在每个 orderer 和 peer 的 msp 目录中来启用的。

# config.yaml
NodeOUs:
  Enable: true
  ClientOUIdentifier:
    Certificate: "cacerts/cacert.pem"
    OrganizationalUnitIdentifier: "client"
  AdminOUIdentifier:
    Certificate: "cacerts/cacert.pem"
    OrganizationalUnitIdentifier: "admin"
  PeerOUIdentifier:
    Certificate: "cacerts/cacert.pem"
    OrganizationalUnitIdentifier: "peer"
  OrdererOUIdentifier:
    Certificate: "cacerts/cacert.pem"
    OrganizationalUnitIdentifier: "orderer"

订购者反复打印以下警告:

2020-08-20 11:35:08.041 UTC [comm.grpc.server] 1 -> INFO 0c3 streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Deliver grpc.peer_address=172.24.0.11:42642 grpc.code=OK grpc.call_duration=792.5µs
2020-08-20 11:35:15.176 UTC [common.deliver] deliverBlocks -> WARN 0c4 [channel: identitych] Client 172.24.0.8:60236 is not authorized: implicit policy evaluation failed - 0 sub-policies were satisfied, but this policy requires 1 of the 'Readers' sub-policies to be satisfied: permission denied

同时,一个对等点也重复打印以下警告:

2020-08-20 11:34:28.604 UTC [peer.blocksprovider] DeliverBlocks -> WARN 02b Got error while attempting to receive blocks: received bad status FORBIDDEN from orderer channel=identitych orderer-address=orderer0.common.bpl:7050
2020-08-20 11:34:28.604 UTC [peer.blocksprovider] func1 -> WARN 02c Encountered an error reading from deliver stream: EOF channel=identitych orderer-address=orderer0.common.bpl:7050

我发现了一个类似的问题和答案 (link),我很好奇以下引用:

检查您在 configtx.yaml 中定义的读取器策略,此错误是由于策略不匹配而生成的。您在 Reader 策略中定义了一些特定的用户类型(admin、peer、client),但此特定用户类型不会传递到您为 peer 生成的证书中。

我同意我的问题是因为政策不匹配,但我不明白以下提及:

但此特定用户类型不会传递到您为同行生成的证书中。

如何解决我的问题?提前谢谢。

【问题讨论】:

    标签: hyperledger-fabric hyperledger


    【解决方案1】:

    您似乎没有为通道配置中包含的 MSP 定义启用 NodeOU。

    NodeOUs 通过将 config.yaml 放在每个 orderer 和 peer 的 msp 目录中来启用。

    这将在 peer 和 orderer 的“本地 MSP”中启用 NodeOU 支持,但对于通道操作,例如调用 Deliver API,使用的是通道 MSP 定义。

    确保您已将您的 config.yaml 放置在您的 configtx.yaml 引用的 MSP 目录中(例如,在您的情况下,在 ./peers/org-msp 下)为排序者生成创世块之前系统频道。

    补充说明:

    您可以通过更改 configtx.yaml 中的读者策略来确认它与 NodeOU 相关,以便为您的对等组织引用 member,就像您对订购者组织所做的那样。如果符合会员政策,那么这肯定与 NodeOU 相关。

    您还可以通过设置FABRIC_LOGGING_SPEC=info:cauthdsl=debug:policies=debug:msp=debug 来打开策略评估的调试。这对于正常操作来说通常过于冗长,但可以让您更清楚地了解导致失败的确切原因。

    【讨论】:

    • 感谢您的评论,我可以解决问题!谢谢!
    猜你喜欢
    • 2019-11-29
    • 1970-01-01
    • 1970-01-01
    • 2017-12-04
    • 2019-11-09
    • 1970-01-01
    • 2020-02-23
    • 2016-12-17
    • 1970-01-01
    相关资源
    最近更新 更多