1

我想从客户端调用链代码命令,我得到Error processing transaction. Error: PEM encoded certificate is required这是我用来连接到结构网络并调用链代码的客户端代码。我可以从对等 cli 调用和执行链代码命令,但为什么我不能从客户端执行它。我认为它可能与 tls 参数或其他东西有关。谁能告诉我我错过了什么。谢谢

`
    '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');}
4

2 回答 2

0

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

于 2020-01-13T11:26:03.803 回答
0

如果您启用了 TLS,您可能缺少证书客户端(Node SDK)。我建议保持启用 TLS 但删除相互身份验证,这样客户端就不必每次都进行身份验证。

您必须更改 docker compose 上的环境变量,将 CLIENTAUTHREQUIRED 设置为 false 并在钱包中为客户端再次生成证书。

于 2020-01-09T14:40:38.290 回答