检查过程中看不到交易的手动签名(结构 1.4)

Manual signings of the transactions are not visibles during checking(fabric 1.4)

我们应该能够签署具有多个身份的交易,这可能是策略中配置的要求。

但是我没有成功,也就是说,我有一个需要多重签名的政策,所以我用两个组织的MSP信息依次签署了交易文件(.tx),但是当我提交那么交易, 订购者或同行将拒绝它,说“签名集不满足策略...”。

奇怪的是,这个检查忽略了我所做的其他签名,它只会考虑提交交易的命令自动完成的签名:peer channel update or 对等链码实例化,就好像 最后一个签名使我之前手动应用的签名无效。

关于我遗漏了什么的一些想法?

我使用的命令:

我修改的不同签名的变量:

-- 已编辑

我正在使用 Fabric 版本 1.4.0 的 first-network 示例:

这是 configtx.yaml 文件中的 Application 部分,我在其中更新了 ANY 的 Writers 策略作者多数管理员

Application: &ApplicationDefaults

# Organizations is the list of orgs which are defined as participants on
# the application side of the network
Organizations:

# Policies defines the set of policies at this level of the config tree
# For Application policies, their canonical path is
#   /Channel/Application/<PolicyName>
Policies:
    Readers:
        Type: ImplicitMeta
        Rule: "ANY Readers"
    Writers:
        Type: ImplicitMeta
        Rule: "MAJORITY Admins"
    Admins:
        Type: ImplicitMeta
        Rule: "MAJORITY Admins"

Capabilities:
    <<: *ApplicationCapabilities

在 cli 容器中,我可以毫无问题地创建通道:

peer channel create --channelID $CHANNEL_ID --orderer orderer.example.com:7050 --tls --cafile $ORDERER_CA --file channel-artifacts/channel.tx

在我加入对等点 peer0.org1.example.com 和 peer0.org2.example.com 之后没有任何问题。

当我尝试提交锚节点创建交易时,问题开始了:

peer channel update --channelID $CHANNEL_ID --orderer orderer.example.com:7050 --tls --cafile $ORDERER_CA --file  channel-artifacts/Org1MSPanchors.tx

我收到错误消息:

Error: got unexpected status: FORBIDDEN -- Failed to reach implicit threshold of 1 sub-policies, required 1 remaining: permission denied

订购者提供了更详尽的日志:http://snippi.com/s/hlxkvl3

日志显示排序者尝试了这些操作来验证交易的签名:

  1. 第 2 行:尝试评估政策 /Channel/Writers
  2. 第 4 行:尝试评估政策 /Channel/Application/Writers
  3. 第 6 行:尝试评估政策 /Channel/Application/Org1MSP/Admins
  4. 第 20 行:签名集满足策略 /Channel/Application/Org1MSP/Admins
  5. 第 22 行:尝试评估政策 /Channel/Application/Org2MSP/Admins
  6. 第 29 行:签名集不满足策略 /Channel/Application/Org2MSP/Admins
  7. 第 31 行:评估失败:仅满足 1 个策略,但需要 [ Org1MSP.Admins Org2MSP.Admins ]
  8. 中的 2 个
  9. 第 34 行:评估政策 /Channel/Orderer/Writers
  10. 第 43 行:签名集不满足策略 /Channel/Orderer/OrdererOrg/Writers
  11. 第 48 行:评估失败:仅满足 0 个策略,但需要 [Application.WritersOrderer.Writers]
  12. 中的 1 个

看到这个错误,我说好的,我先用Org1的admin签名交易,然后用Org2的admin签名提交:

peer channel signconfigtx -f channel-artifacts/Org1MSPanchors.tx

CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org2MSP
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
CORE_PEER_ID=peer0.org2.example.com
CORE_PEER_ADDRESS=peer0.org2.example.com:7051

peer channel update --channelID $CHANNEL_ID --orderer orderer.example.com:7050 --tls --cafile $ORDERER_CA --file  channel-artifacts/Org1MSPanchors.tx

我收到错误信息:

Error: got unexpected status: FORBIDDEN -- Failed to reach implicit threshold of 1 sub-policies, required 1 remaining: permission denied

来自排序者的日志:http://snippi.com/s/qjb7dlv

这次日志显示orderer首先找不到Org1管理员的签名(例如第28行),然后找到Org2管理员的签名(第45行)。并且 /Channel/Application/Writers/Channel/Orderer/OrdererOrg/Writers 这两个策略均未满足(第 64 行)。

我可以看到当我签名时交易文件的大小增加了,证明文件被很好地修改了。但是为什么在控制过程中订购者所期望的这个签名似乎对它不可见?

只是为了继续前进,作为临时解决方法,我使用排序者的管理 MSP 来提交锚节点的交易:

CORE_PEER_LOCALMSPID=OrdererMSP
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/users/Admin\@example.com/msp/

peer channel update --channelID $CHANNEL_ID --orderer orderer.example.com:7050 --tls --cafile $ORDERER_CA --file  channel-artifacts/Org1MSPanchors.tx

这次命令成功了。但奇怪的是,它之所以起作用,只是因为我之前使用 Org1 的管理 MSP 签署了交易,也就是说,如果我尝试使用订购者的管理 MSP 提交交易而没有使用 Org1 的管理 MSP 签名,它会失败。再次奇怪,如果我首先与订购者的管理员签署交易,然后通过 Org1 的管理员提交它,命令再次失败。

当我尝试实例化链代码时,我遇到了同样的问题,正如我们在排序节点的日志中看到的那样:http://snippi.com/s/324asxa

如果能深入了解 Fabric 的签名机制如何工作,那就太好了。

读者和作者策略必须能够通过单个签名来满足,因为交易格式只允许一个签名。

Admins 策略是用于管理通道配置变更(例如修改 Readers 或 Writers 策略)的默认策略。通道配置的变化确实支持通过 peer channel signconfigtx.

的多重签名工作流程

We are supposed to be able to sign a transaction with multiple identities, and that can be a requirement configured in the policies.

某些交易,例如配置更新交易,可能会使用多个身份进行签名。其他交易,比如链码调用(包括像 peer chaincode instantiate 这样的 lscc 调用)通常只能有一个签名者。

But I'm failing to make this working, that is, I have a policy requiring multi signatures, so I sign the transaction file(.tx) successively with the MSP information of the two organizations, but when I submit the transaction then, the orderer or the peers will reject it, saying that "Signature set did not satisfy policy ...".

如果这是配置更新,那么粘贴更多日志会有所帮助。大多数情况下,如果 CORE_PEER_LOCALMSPIDCORE_PEER_MSPCONFIGPATH 变量设置正确,则策略不满足,因为身份不满足要求的规则(通常 'admin')。

如果这是一个正常的链码调用,比如生命周期操作,那么网络配置错误,因为这些调用必须能够通过单个提交者签名来满足。

https://hyperledger-fabric.readthedocs.io/en/release-1.4/commands/peerchannel.html#peer-channel-signconfigtx

此命令确实旨在允许您为配置更新收集多个签名。

https://hyperledger-fabric.readthedocs.io/en/release-1.4/commands/peerchaincode.html#peer-chaincode-signpackage

这个命令不是特别有用,而且可能有点误导。它添加签名以便管理员可以手动验证协议,但在评估任何结构策略时不使用这些签名。