hyperledger-fabric - 当我尝试使用 Hyperledger Fabric 创建 channel 时,请求失败

标签 hyperledger-fabric

当我尝试使用 Hyperledger Fabric 创建 channel 时,请求失败并返回以下错误:

客户端日志:

Error: got unexpected status: BAD_REQUEST -- error validating channel creation transaction for new channel 'testchannel', could not succesfully apply update to template configuration: error authorizing update: error validating DeltaSet: policy for [Group] /Channel/Application not satisfied: implicit policy evaluation failed - 0 sub-policies were satisfied, but this policy requires 1 of the 'Admins' sub-policies to be satisfied

最佳答案

当提交请求的身份(由 MSP ID、证书和 key 组成)存在问题时,会发生此错误。如果您使用默认的 Fabric 配置策略,则需要由组织管理员创建 channel 。该错误是由于您的身份无法满足 /Channel/Application/Admins 上的默认策略而产生的。小路。

政策拒绝您的身份有多种原因,包括使用无效或过期的证书。您可以通过查看订购者日志来详细了解请求失败的原因。 Ordering Service 是执行创建或更新 channel 的策略的节点。

当您检查订购者日志时,查找与返回给客户的错误类似的错误。您可能会在策略错误(主体反序列化失败)之前的证书检查中发现错误。这意味着 channel 创建被拒绝,因为 MSP ID 未被识别为有效。

订购服务日志:

2019-08-06 15:31:43.589 UTC [cauthdsl] deduplicate -> ERRO 021 Principal deserialization failure
(MSP SampleOrg is unknown) for identity 0
2019-08-06 15:31:43.589 UTC [orderer.common.broadcast] ProcessMessage -> WARN 022 [channel:
testchannel] Rejecting broadcast of config message from 172.27.0.7:34750 because of error: error
validating channel creation transaction for new channel 'testchannel', could not succesfully apply
update to template configuration: error authorizing update: error validating DeltaSet: policy for
[Group]  /Channel/Application not satisfied: implicit policy evaluation failed - 0 sub-policies
were satisfied, but this policy requires 1 of the 'Admins' sub-policies to be satisfied

身份 0 的策略警告之前的错误 ERRO 021 Principal deserialization failure (MSP SampleOrg is unknown),表明作为请求参数传递的 MSP ID 未被排序服务识别。这可能是将错误的 MSP ID 传递给命令的结果。此错误也可能表示您的组织尚未加入由订购服务系统 channel 托管的联盟。如果您正在更新应用程序 channel ,并且您的组织还不是您尝试更新的 channel 的成员,则可能会发生此错误。

如果身份的 MSP ID 有效,可能会遇到以下证书验证错误:

订购服务日志:
2019-08-06 15:34:45.730 UTC [cauthdsl] deduplicate -> ERRO 02d Principal deserialization failure
(the supplied identity is not valid: x509: certificate signed by unknown authority) for identity 0
2019-08-06 15:34:45.730 UTC [orderer.common.broadcast] ProcessMessage -> WARN 02e [channel:
testchannel] Rejecting broadcast of config message from 172.27.0.7:36214 because of error: error
validating channel creation transaction for new channel 'testchannel', could not succesfully apply
update to template configuration: error authorizing update: error validating DeltaSet: policy for
[Group]  /Channel/Application not satisfied: implicit policy evaluation failed - 0 sub-policies
were satisfied, but this policy requires 1 of the 'Admins' sub-policies to be satisfied

在这种情况下,订购服务识别了您的 MSP ID,但无法验证您的证书是否由您组织的证书颁发机构之一颁发。如果您管理多个组织,则此错误可能是由于您使用不匹配的 MSP ID 和证书来提交请求。如果您的管理员证书已过期,也可能发生此错误。如果这是最近启动的测试网络,则您可能正在从由证书颁发机构在您网络的较旧版本上创建的身份发出请求。

更常见的是您的证书已通过验证检查,但无法满足 channel 创建策略。如果是这种情况,您的订购者日志中的错误将如下所示:

订购服务日志:
2019-08-06 15:36:52.307 UTC [orderer.common.broadcast] ProcessMessage -> WARN 032 [channel:
testchannel] Rejecting broadcast of config message from 172.27.0.7:37236 because of error: error
validating channel creation transaction for new channel 'testchannel', could not succesfully apply
update to template configuration: error authorizing update: error validating DeltaSet: policy for
[Group]  /Channel/Application not satisfied: implicit policy evaluation failed - 0 sub-policies
were satisfied, but this policy requires 1 of the 'Admins' sub-policies to be satisfied

提交请求的身份是贵组织的有效成员,贵组织被识别为系统 channel 或应用 channel 的成员。但是,该身份没有创建 channel 的权限。您可能在提交请求时使用了错误的身份,并且使用了不是您的组织管理员的身份。以管理员身份提交请求,或创建新管理员,并让 channel 管理员更新您的组织 MSP。

如果您在 channel 创建以外的操作中遇到此错误,则您的证书可能未获得正确角色的授权。检查您的客户端证书和对等证书是否分别具有客户端和对等 OU。

其他调试技术

如果您需要额外的帮助来调试与策略或证书相关的错误,您可以增加与这些组件相关的日志记录级别:
FABRIC_LOGGING_SPEC=”WARN:cauthdsl=debug:policies=debug:msp=debug

您还可以从应用程序或系统 channel 手动提取您的组织根证书,并使用它们来验证您的客户端证书。使用以下命令从您的 channel 中提取最新的配置块。
peer channel fetch config ./configupdate/config_block.pb -o <orderer_endpoint> -c <my_channel> --tls --cafile <PATH_TO_ORDERER_TLS_CERT>

然后使用以下命令将配置块转换为 JSON。
configtxlator proto_decode –type=common.Block --input=config_block.pb --output=config_block.json

这允许您使用以下命令从块中提取根证书。替换为您组织的 MSP ID。
jq -r .data.data[0].payload.data.config.channel_group.groups.Application.groups.<MSPID>\
.values.MSP.value.config.root_certs[0] config_block.json | base64 –decode > root.pem

如果您的 MSP 定义了多个根证书或使用中间证书,您将需要调整上面的 jq 命令以正确提取它们。

然后,您可以使用 OpenSSL 等工具根据根证书验证客户端管理证书。
openssl verify -CAFile <root.pem> <admincert.pem>

您还可以使用以下命令打开证书并以明文形式检查它。这允许您检查诸如到期日期、节点 OU 或颁发 CA 之类的字段。
openssl x509 -in <admincert.pem> -text

关于hyperledger-fabric - 当我尝试使用 Hyperledger Fabric 创建 channel 时,请求失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57662562/

相关文章:

node.js - npm 安装 Fabric-ca-client 失败

blockchain - super 账本结构在哪里存储区 block 链的数据库?

hyperledger-fabric - Fabric CA 中的 hf.Registrar.Roles 和 hf.Registrar.DelegateRoles 有什么区别?

blockchain - Hyperledger 中的交易证书如何用于加强隐私保护?

hyperledger-fabric - gRPC 失败,在多个节点上的 Hyperledger Fabric 区 block 链上执行链代码时

hyperledger-fabric - 如何在 hyperledger composer 中保护参与者卡?

docker - Hyperledger byfn的问题-ERRO 002无法运行对等,因为无法初始化加密

docker - 尝试在OSX上部署bna文件时,Fabric Composer快速启动失败

hyperledger-fabric - 颁发身份 super 账本 Composer 时授权失败

go - 在 HyperLedger Fabric 中对等节点安装链码