簡體   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