Error: Invalid private key | Hyperledger Fabric Node SDK

Error: Invalid private key | Hyperledger Fabric Node SDK

我正在使用余额转账示例

我在订购者容器中启用了 ORDERER_GENERAL_TLS_CLIENTAUTHREQUIRED=true

创建新频道 (mychannel) 时抛出 Handshake failed with fatal error

错误

错误后我配置了客户端

client.setTlsClientCertAndKey(cert, key);

 let adminClient = JSON.parse(
      fs.readFileSync(path.join(__dirname, "../fabric-client-kv-org1/admin"))
    );
    logger.info(adminClient);

    client.setTlsClientCertAndKey(
      adminClient.enrollment.identity.certificate,
      adminClient.enrollment.signingIdentity
    );

我正在导入 admin,然后使用其 signingIdentity 和证书来设置 tls 客户端。

现在,它抛出错误 Invalid private key

E0619 17:15:44.135000000 139448 ssl_transport_security.cc:671] Invalid private key.
E0619 17:15:44.136000000 139448 security_connector.cc:1087] Handshaker factory creation failed with TSI_INVALID_ARGUMENT.
E0619 17:15:44.137000000 139448 secure_channel_create.cc:121] Failed to create secure subchannel for secure name 'localhost:7050'
E0619 17:15:44.137000000 139448 secure_channel_create.cc:154] Failed to create subchannel arguments during subchannel creation.
2019-06-19T11:45:47.132Z - error: [Remote.js]: Error: Failed to connect before the deadline URL:grpcs://localhost:7050
2019-06-19T11:45:47.133Z - error: [Orderer.js]: Orderer grpcs://localhost:7050 has an error Error: Failed to connect before the deadline URL:grpcs://localhost:7050

错误的原因是什么?我使用的客户端证书和密钥是否正确?它在文档中令人困惑

https://fabric-sdk-node.github.io/tutorial-network-config.html

找到私钥无效的原因了。签名身份不是私钥。

注册用户后,我正在注册并将其私钥和证书保存在本地。

 let req = {
      enrollmentID: "admin",
      enrollmentSecret: "adminpw",
      profile: "tls"
    };

    const enrollment = await caClient.enroll(req);
client.setTlsClientCertAndKey(
      enrollment.certificate,
      enrollment.key.toBytes()
    );