为组织添加用户时,常见的连接配置文件缺少错误 [英] Common connection profile missing error while adding user for organization

查看:93
本文介绍了为组织添加用户时,常见的连接配置文件缺少错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了

Error: Common connection profile is missing this client's organization and certificate authority 

在运行gateway.getClient().getCertificateAuthority()代码行时出错.我的连接配置文件在那里,据我所知它没有问题.

Error, while running gateway.getClient().getCertificateAuthority() code line. My connection profile file is there and as per my understanding it has no issues.

以下是我的nodejs客户端代码.

Following is my nodejs client code.

'use strict';

const { FileSystemWallet, Gateway, X509WalletMixin } = require('fabric-network');
const path = require('path');

const ccpPath = "../connection-ogr4.json";

async function main() {
    try {

        let user = 'user2';
        // Create a new file system based wallet for managing identities.
        const walletPath = path.join(process.cwd(), 'wallet');
        const wallet = new FileSystemWallet(walletPath);
        console.log(`Wallet path: ${walletPath}`);

        const userExists = await wallet.exists(user);

        // Check to see if we've already enrolled the admin user.
        const adminExists = await wallet.exists('admin');

        // Create a new gateway for connecting to our peer node.
        const gateway = new Gateway();
        await gateway.connect(ccpPath, { wallet, identity: 'admin', discovery: { enabled: true, asLocalhost: true } });
        // Get the CA client object from the gateway for interacting with the CA.
        const ca = gateway.getClient().getCertificateAuthority()

它使用以下连接json文件.

It uses the following connection json file.

{
"name": "network-org4",
"version": "1.0.0",
"client": {
    "organization": "Org4",
    "connection": {
        "timeout": {
            "peer": {
                "endorser": "300"
            }
        }
    }
},
"organizations": {
    .......
},
"certificateAuthorities": {
    "ca.org4.bc4scm.de": {
        "url": "https://localhost:9054",
        "caName": "ca-org4",
        "tlsCACerts": {
            "path": "crypto-config/peerOrganizations/org4.bc4scm.de/tlsca/tlsca.org4.bc4scm.de-cert.pem"
        },
        "httpOptions": {
            "verify": false
        }
    }
}

}

此问题的原因是什么?欣赏您的见解.

What is the reason for this issue? Appreciate your insights.

推荐答案

可能存在渠道",订购者,同行,失踪.有关更多的信息,您可以参考-

There might be "channels", orderers, peers ,missing.For more insight you could refer - https://fabric-sdk-node.github.io/tutorial-network-config.html Meanwhile below is the running snippet, you only need to change the configuration according to your network.

{
  "name": "dockercompose_default",
  "version": "1.0",
  "client": {
     "organization": "org1",
     "connection": {
         "timeout": {
             "peer": {
                 "endorser": "300"
             },
             "orderer": "300"
         }
     }
 },
  "channels": {
      "common": {
          "orderers": [
              "orderer.example.com"
          ],
          "peers": {
              "peer0.org.example.com": {
                  "endorsingPeer": true,
                  "chaincodeQuery": true,
                  "ledgerQuery": true,
                  "eventSource": true
              },
              "peer1.org.example.com": {
                  "endorsingPeer": true,
                  "chaincodeQuery": false,
                  "ledgerQuery": true,
                  "eventSource": false
              }

          }
      },
      "a-b": {
          "orderers": [
              "orderer.example.com"
          ],
          "peers": {
              "peer0.org.example.com": {
                  "endorsingPeer": true,
                  "chaincodeQuery": true,
                  "ledgerQuery": true,
                  "eventSource": true
              },
              "peer1.org.example.com": {
                  "endorsingPeer": true,
                  "chaincodeQuery": false,
                  "ledgerQuery": true,
                  "eventSource": false
              }

          }
      }
  },
  "organizations": {
      "org1": {
          "mspid": "org1MSP",
          "peers": [
              "peer0.org.example.com",
              "peer1.org.example.com"
          ],
          "certificateAuthorities": [
              "ca.org.example.com"
          ],
          "adminPrivateKey": {
              "path": "../artifacts/crypto-config/peerOrganizations/org.example.com/users/Admin@org.example.com/msp/keystore/d30f6a06fa605d23da82f7f98bce3c00b37707f6363ca698331c6a1d834c47d4_sk"
          },
          "signedCert": {
              "path": "../artifacts/crypto-config/peerOrganizations/org.example.com/users/Admin@org.example.com/msp/signcerts/Admin@org.example.com-cert.pem"
          }
      }    
  },
  "orderers": {
      "orderer.example.com": {
          "url": "grpcs://localhost:7050",
          "grpcOptions": {
              "ssl-target-name-override": "orderer.example.com",
              "grpc-max-send-message-length": -1
          },
          "tlsCACerts": {
              "path": "../artifacts/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt"
          }
      }
  },
  "peers": {
      "peer0.org.example.com": {
          "url": "grpcs://localhost:7051",
          "eventUrl": "grpcs://localhost:7053",
          "grpcOptions": {
              "ssl-target-name-override": "peer0.org.example.com",
              "grpc.keepalive_time_ms": 600000
          },
          "tlsCACerts": {
              "path": "../artifacts/crypto-config/peerOrganizations/org.example.com/peers/peer0.org.example.com/tls/ca.crt"
          }
      },
      "peer1.org.example.com": {
          "url": "grpcs://localhost:7056",
          "eventUrl": "grpcs://localhost:7058",
          "grpcOptions": {
              "ssl-target-name-override": "peer1.org.example.com"
          },
          "tlsCACerts": {
              "path": "../artifacts/crypto-config/peerOrganizations/org.example.com/peers/peer1.org.example.com/tls/ca.crt"
          }
      }        
  },
  "certificateAuthorities": {
      "ca.org.example.com": {
          "url": "https://localhost:7054",
          "httpOptions": {
              "verify": true
          },
          "tlsCACerts": {
              "path": "../artifacts/crypto-config/peerOrganizations/org.example.com/peers/peer0.org.example.com/tls/ca.crt"
          },
          "registrar": [
              {
                  "enrollId": "admin",
                  "enrollSecret": "adminpw"
              }
          ],
          "caName": "ca.org.example.com"
      }        
  }
}

这篇关于为组织添加用户时,常见的连接配置文件缺少错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆