2

I am having this problem while connecting to fabric client using Node SDK. I refer to this Error adding new Peer in Hyperledger Fabric and I think this is also what I need to fix my problem. However I am confused as to what PEM file I should point it to. It will help if someone could provide a sample path of the PEM file. Thank you. Hope someone help.

Jeson
  • 251
  • 4
  • 14

1 Answers1

2

I suppose you found a way back then, but here is the solution i found:

The PEM certificate you should point to is inside the crypto-config folder for the peer (i'm assuming you use cryptogen here, as stated in the fabric tutorial)

So the file should be located as such :

crypto-config/peerOrganizations/PEER ORG NAME/peers/PEER NAME/msp/tlscacerts/tlsca.PEER ORG NAME-cert.pem

To be more complete, it seems that specifying the path to the certificate in the newPeer() call as stated in the response you found doesn't cut it, since it needs the actual content of the file it this place.

So you will need to write the file content's there, by doing something like this:

      var channel = fabric_client.newChannel(channel);

      const fs = require('fs');
      let serverCert = fs.readFileSync('PATH_TO_PEM_CERT');
      var peer = fabric_client.newPeer(peerAddr, { pem :  Buffer.from(serverCert).toString() });

      channel.addPeer(peer);