Error: Failed to import identity. Error: privateKey not specified or not a string

Error: Failed to import identity. Error: privateKey not specified or not a string

我用我之前申请的管理卡创建了我的网络,但是当我想将这张卡导入卡存储时错误:

Failed to import identity. Error: privateKey not specified or not a string

导入失败。

我的操作是: 1. 创建 PeerAdmin 卡片:

composer card create -p ./santai/byfn-network-test.json -u PeerAdmin -c ./santai/Admin@santai.chembeango.com-cert.pem -k ./santai/689f471246b0e180384660285aff48dcc5e12b9fd6bed4e5a47cce7ce367310f_sk -r PeerAdmin -r ChannelAdmin -f PeerAdmin@chembeango-network-test.card

  1. 将 PeerAdmin 卡片导入卡片商店:

    composer card import -f PeerAdmin@chembeango-network-test.card --card PeerAdmin@chembeango-network-test

  2. 身份请求:

作曲者身份请求-c PeerAdmin@chembeango-network-test -u test -s t789456 -d test

  1. 启动网络

composer network start -c PeerAdmin@chembeango-network-test -n chembeango-test-network -V 0.0.1 -o endorsementPolicyFile=./endorsement-policy.json -A test -C test/test-pub.pem

  1. 导入管理卡

    composer card import -f test@chembeango-test-network.card

我检查了我的 priv pem,它是:

-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgGPwysYDw6+TLcgiv
QOHt7vhm3j5A9muqwmIKutoxdhGhRANCAASDNP95hp3tpLda5qGD2LTSfpjD4x4t
mqYlov5eIQhG1Nq7BXdn0fJYtpPB5T5odaoheUU0xDcC4BXAmqb9LYif
-----END PRIVATE KEY-----

我把我的卡压缩成一个zip文件,然后解压,结构是:

 extracting: connection.json
 extracting: metadata.json
   creating: credentials/
 extracting: credentials/certificate

我没有找到私钥,是这个问题吗?

你没看错,自动为你创建的卡中没有私钥!

您需要删除自动生成的卡并自己创建一张包含证书和密钥的新卡。所以你将需要 2 个命令 similar - 我建议使用 'test2' 这样就不会混淆:

composer card create -p ./santai/byfn-network-test.json -u test -c test/test-pub.pem -k test/test-priv.pem -f test2.card -n chembeango-test-network

composer card import -f test2.card -c test2@chembeango

(如果您在 composer network start 命令中指定用户名和密码,自动生成的卡片在单一组织环境中工作正常,但如果您先请求身份,然后在启动命令中使用证书,生成的卡片不会不包含私钥)

我解决了这个问题。 我的操作是:

  1. 将测试 priv pem 添加到 credentials 文件夹,
  2. 将其重命名为 PrivateKey
  3. 我将这些文件压缩为 zip 文件。
  4. 将此 zip 文件重命名为 card
  5. 将卡片导入卡片商店。有效!