1

i am tring to invoke chaincode command from client by i get 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');}
Mike Araya
  • 155
  • 1
  • 11

2 Answers2

0

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.

Riki95
  • 706
  • 1
  • 7
  • 16
  • which docker compose file? i couldn't find CLIENTAUTHREQUIRED in my configs – Mike Araya Jan 09 '20 at 14:45
  • CORE_PEER_TLS_CLIENTAUTHREQUIRED was not set in the environment, but even after setting it the error is still there. is there a way to pass the private key to the gateway function – Mike Araya Jan 09 '20 at 15:00
  • Yes, there is, but you will not solve. I tried several times and I think there is a bug on the SDK, this is why I suggest to use no client authentication from the client ;) I am using TLS but no Mutual TLS and is working fine – Riki95 Jan 10 '20 at 10:40
0

the problem was in the connection configuration yaml file after specifying the ca address which was not available at the time everything worked.

Mike Araya
  • 155
  • 1
  • 11