Отсутствует общая ошибка профиля подключения при добавлении пользователя в организацию - PullRequest
1 голос
/ 01 июля 2019

Я получаю

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

Ошибка при выполнении gateway.getClient().getCertificateAuthority() строки кода.У меня есть файл профиля подключения, и, насколько я понимаю, у него нет проблем.

Ниже приведен код моего клиента nodejs.

'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 подключения.

{
"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
        }
    }
}

}

В чем причина этой проблемы?Цените ваши идеи.

1 Ответ

3 голосов
/ 02 июля 2019

Возможно, отсутствуют «каналы», заказчики, одноранговые узлы. Для получения дополнительной информации вы можете обратиться к https://fabric -sdk-node.github.io / tutorial-network-config.html Тем временем нижеэто запущенный фрагмент, вам нужно только изменить конфигурацию в соответствии с вашей сетью.

{
  "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"
      }        
  }
}
...