Hyperledger Fabric通过1.4.4对等本地MSP加入通道

时间:2019-12-04 03:38:22

标签: hyperledger-fabric hyperledger

AFAIK,超级账本结构1.4.4通过在msp目录内创建config.yaml文件来允许“ NodeOU”。

我正在尝试与本地对等msp一起加入网络。但是网络总是返回错误以下。 Error: proposal failed (err: bad proposal response 500: access denied for [JoinChain][myorg]: [Failed verifying that proposal's creator satisfies local MSP principal during channelless check policy with policy [Admins]: [The identity is not an admin under this MSP [MYORG]: The identity does not contain OU [ADMIN], MSP: [MYORG]]])

我对等方的本地msp目录的结构也具有

msp
  `- admincerts
  `- cacerts
         `- ca-cert.pem
  `- signcerts
         `- signcert.pem
  `- keystore
         `- secret
  `- config.yaml

msp/config.yaml的内容如下。

NodeOUs:
  Enable: true
  ClientOUIdentifier:
    Certificate: cacerts/ca-cert.pem
    OrganizationalUnitIdentifier: client
  PeerOUIdentifier:
    Certificate: cacerts/ca-cert.pem
    OrganizationalUnitIdentifier: peer
  AdminOUIdentifier:
    Certificate: cacerts/ca-cert.pem
    OrganizationalUnitIdentifier: admin
  OrdererOUIdentifier:
    Certificate: cacerts/ca-cert.pem
    OrganizationalUnitIdentifier: orderer

我的猜测是NodeOUs可以正常工作,因为在没有admincerts的情况下启动对等体没有问题。因此,我认为我需要配置频道加入策略,但找不到任何策略引用。

2 个答案:

答案 0 :(得分:4)

在您的configtx.yaml中检查组织策略,该策略与此非常相似:

1. For orderer:

    Readers:
    Type: Signature
    Rule: "OR('ordererMSP.member')"
    Writers:
    Type: Signature
    Rule: "OR('ordererMSP.member')"
    Admins:
    Type: Signature
    Rule: "OR('ordererMSP.member')"

2. For MYORG:

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

现在,因为订购者的策略是通用的,所以创世块的创建效果很好。但是问题开始于对等方尝试加入频道的过程,因为对等组织的策略特定于管理员,对等方或客户端的用户类型。

因此,要解决此问题,您必须在通过Fabric-CA注册证书时,将 OU 作为管理员,对等方,客户端或订购方传递给您的证书。这样,只有该证书对于使用这些证书进行特定操作才有效。这是生成管理员证书的示例:

fabric-ca-client enroll --caname ca.example.com --csr.names C=SG,ST=Singapore,L=Singapore,O=$ORG_NAME,OU=admin -m admin -u http://admin:adminpw@localhost:$PORT

答案 1 :(得分:0)

检查您使用的configtx.yaml是否具有(至少):

Capabilities:
    Channel: &ChannelCapabilities
        V1_4_3: true
        V1_1: true

在用于加入对等方的客户端中,运行(检查证书路径):

openssl x509 -text -noout -in $CORE_PEER_MSPCONFIGPATH/signcerts/signcert.pem

检查OU是否包含admin

您还可以检查证书是否由myorg的CA签名:

openssl verify -CAfile path-to-myorg-msp-as-specified-in-configtx-yaml/cacerts/ca-cert.pem $CORE_PEER_MSPCONFIGPATH/signcerts/signcert.pem

此处有更多信息:https://hyperledger-fabric.readthedocs.io/en/release-1.4/msp.html#identity-classification