简体   繁体   中英

unable to invoke chaincode from client : Error processing transaction. Error: PEM encoded certificate is required

i am tring to invoke chaincode command from client by i get Error processing transaction. Error: PEM encoded certificate is required Error processing transaction. Error: PEM encoded certificate is required this is my client code i am using to connect to the fabric network and invoke the chaincode. i can invoke and execute chaincode commands from the peer cli but why can't i do it from a client. i think it might have to do something with tls parameter or something. can anyone tell me what i'm missing. thanks

`
    'use strict';
    const fs = require('fs');
    const yaml = require('js-yaml');
    const { FileSystemWallet, Gateway } = require('fabric-network');
    const CommercialPaper = require('../chaincode/lib/paper');

   // A wallet stores a collection of identities for use
    const wallet = new FileSystemWallet('../identity/user/isabella/wallet');

  async function main() {

         const gateway = new Gateway();


   try {
          const userName = 'User1@org1.bionic.com';

         // Load connection profile; will be used to locate a gateway             
        let connectionProfile = 
        yaml.safeLoad(fs.readFileSync('../gateway/networkConnection.yaml', 'utf8')
        );

// Set connection options; identity and wallet
let connectionOptions = {
  identity: userName,
  wallet: wallet,
  discovery: { enabled: false, asLocalhost: true }
};

await gateway.connect(connectionProfile, connectionOptions);

const network = await gateway.getNetwork('bionicchannel');
console.error('error occured');

// Get addressability to commercial paper contract

const contract = await network.getContract('papercontract');

const issueResponse = await contract.submitTransaction(
  'issue',
  'BionicSoftware',
  '00001',
  '2020-05-31',
  '2020-11-30',
  '5000000');}

If you have TLS enabled, you are probably missing certificates client side (Node SDK). I suggest to keep TLS enabled but remove mutual authentication, in this way the client does not have to autentify each time.

You must change environment variables on docker compose setting CLIENTAUTHREQUIRED to false and generating again certificates in the wallet for the client.

问题出在连接配置 yaml 文件中,指定了在一切正常时不可用的 ca 地址。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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