繁体   English   中英

Hyperledger Composer BusinessNetwork连接-0.14.3无法连接

[英]Hyperledger Composer BusinessNetwork Connection - 0.14.3 cannot connect

我正在尝试将BusinessNetworkConnection用于NodeJS,但是如何从操场上已部署的BNA获取凭据并将其保存在服务器目录中?

我正进入(状态

2017-11-03T13:07:32.83-0400 [APP/PROC/WEB/0] ERR (node:62) 
UnhandledPromiseRejectionWarning: Unhandled promise rejection 
(rejection id: 1): Error: Error trying login and get user Context. 
Error: Error trying to enroll user or load channel configuration. 
Error: Enrollment failed with errors 
[[{"code":400,"message":"Authorization failure"}]]

当我尝试使用代码

const BusinessNetworkConnection = require("composer-client").BusinessNetworkConnection;
this.businessNetworkConnection = new BusinessNetworkConnection();
this.CONNECTION_PROFILE_NAME = "ibm-bc-org1";
this.businessNetworkIdentifier = "giveback";
this.businessNetworkConnection
  .connect(
    this.CONNECTION_PROFILE_NAME,
    this.businessNetworkIdentifier,
    "admin",
    "adminpw"
  )
  .then(result => {
    this.businessNetworkDefinition = result;
    console.log("BusinessNetworkConnection: ", result);
  })

我有一个目录/home/vcap/app/.composer-connection-profiles/ibm-bc-org1其中带有connection.json文件,该文件引用了/home/vcap/app/.composer-credentials/ibm-bc-org1证书。 该代码适用于composer@0.13.2但现在我转到了composer@0.14.3 我删除了以前的凭据,并创建了一个新的游乐场等,一切都是新鲜干净的。

当发生这种情况时,有一种解决方法。 因为我正在尝试使用admin || adminpw连接Composer创建的凭证。 admin || adminpw 您可以只在模型文件中定义一个新的参与者,然后授予该参与者系统权限以查询和侦听Historian发出的事件。

例如在您的model.cto

participant ServerAdmin identified by serverhash {
  // ServerAdmin is a type of participant 
  o String serverhash
}

然后在您的permissions.acl添加:

rule ServerAdminUser {
  description: "Grant business network administrators full access to 
  user resources"
  participant: "org.acme.sample.ServerAdmin"
  operation: ALL
  resource: "**"
  action: ALLOW
}

rule ServerAdminSystem {
  description: "Grant business network administrators full access to system resources"
  participant: "org.acme.sample.ServerAdmin"
  operation: ALL
  resource: "org.hyperledger.composer.system.**"
  action: ALLOW
}

然后,在Composer在操场上部署网络之后,您可以通过REST API通过VIA添加此参与者,并为其发出新的标识。 这将为您提供一个User IDUser Secret ,您可以在BusinessNetworkConnection.connect()使用该User IDUser Secret

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM