hyperledger结构:找不到与SKI匹配的私钥

时间:2018-06-19 17:32:15

标签: hyperledger-fabric

这是我关于stackoverflow的第一篇文章,通常我每次都进入stackoverflow时都找到了解决方案,但这次不是:(

我正在尝试为供应链实施超级账本结构解决方案。 我可以执行通道,chaincode,addpeers ...我也可以通过终端实例化和调用chaincode。

我想创建一个与节点sdk能够与我的区块链进行交互的应用程序,因此我想使用fabric-ca。以下是我的docker-compose-base.yaml文件:

ca_acheteur.example.com:
 image: hyperledger/fabric-ca
 environment:
   - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
   - FABRIC_CA_SERVER_CA_NAME=ca_acheteur.example.com                               
   - FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.acheteur.example.com-cert.pem
   - FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/abef4d982d505c588c15bf25af3270f403c94daff71301e37a9c84abe41e6c71_sk
 ports:
   - "7054:7054"
 command: sh -c 'fabric-ca-server start -b admin:adminpw'
 volumes:
   - ./crypto-config/peerOrganizations/org1.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
 container_name: ca_acheteur.example.com
 networks:
   - basic
ca_vendeur.example.com:
 image: hyperledger/fabric-ca
 environment:
   - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
   - FABRIC_CA_SERVER_CA_NAME=ca_vendeur.example.com
   - FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.vendeur.example.com-cert.pem
   - FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/42ecb9a24235f691c5392d7eecebc458827b00bf0bf150fd727298b321b6d51d_sk
 ports:
   - "8054:8054"
 command: sh -c 'fabric-ca-server start -b admin:adminpw'
 volumes:
   - ./crypto-config/peerOrganizations/vendeur.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
 container_name: ca_vendeur.example.com
 networks:
   - basic

启动容器时,我得到以下结果:

Creating ca_acheteur.example.com           ... done
Creating peer0.acheteur.example.com        ... done
Creating peer0.vendeur.example.com         ... done
Creating ca_vendeur.example.com            ... done
Creating orderer.example.com               ... done
Creating couchdb                           ... done
Creating cli                               ... done

CA容器失败,下面是docker日志:

2018/06/19 17:10:01 [INFO] Created default configuration file at /etc/hyperledger/fabric-ca-server/fabric-ca-server-config.yaml
2018/06/19 17:10:01 [INFO] Starting server in home directory: /etc/hyperledger/fabric-ca-server
2018/06/19 17:10:01 [INFO] Server Version: 1.1.0
2018/06/19 17:10:01 [INFO] Server Levels: &{Identity:1 Affiliation:1 Certificate:1}
Error: Failed to find private key for certificate in '/etc/hyperledger/fabric-ca-server-config/ca.vendeur.example.com-cert.pem': Could not find matching private key for SKI: Failed getting key for SKI [[159 75 128 227 121 9 61 98 235 18 118 191 43 69 158 184 170 52 121 51 27 147 132 228 64 195 35 218 6 9 158 30]]: Key with SKI 9f4b80e379093d62eb1276bf2b459eb8aa3479331b9384e440c323da06099e1e not found in /etc/hyperledger/fabric-ca-server/msp/keystore

FABRIC_CA_SERVER_CA_KEYFILE与我对等的本地ca相同。

让我知道我在这里想念什么。

4 个答案:

答案 0 :(得分:2)

我的错误与op相同,但只有一台ca服务器。

我发现的唯一解决方法是在生成FABRIC_CA_SERVER_KEYFILE环境变量以使其与私钥名称匹配之后。

编辑:搜索了结构示例中的配置之后,我看到他们在docker-compose-e2e.yaml中的ca配置中将其命名为CA2_PRIVATE_KEY。

https://github.com/hyperledger/fabric-samples/blob/master/first-network/byfn.sh第271-281行中生成后,它会自动重命名。

答案 1 :(得分:0)

这是ca的私钥的问题。 执行generate.sh脚本后,将生成新证书。因此,您将不得不更新docker-compose.yml文件。

从路径粘贴文件名-> crypto- config / peerOrganizations / org1.example.com / ca /​​ _____- sk

在docker-compose.yml文件中---->

环境

-FABRIC_CA_SERVER_CA_KEYFILE = / etc / hyperledger / fabric-ca-server-config / ___- sk

答案 2 :(得分:0)

我只是遇到了同样的问题。我不知道您使用的是什么操作系统,但是我在Windows上遇到了这个问题。 Fabric文档指定:If you are using Docker Toolbox on Windows 7 or macOS, you will need to use a location under C:\Users (Windows 7) or /Users (macOS) when installing and running the samples.

当我将项目移动到用户文件夹时,它开始工作。

答案 3 :(得分:0)

我遵循了建议“在生成FABRIC_CA_SERVER_KEYFILE环境变量以使其与私钥名称匹配之后”。它正在工作!!!!!

我的错误:

Error: Failed to find private key for certificate in '/etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem': Could not find matching private key for SKI: Failed getting key for SKI [[......]: Key with SKI 300dbdb3ba348ba85045c40fa3f6985cc1c9f9e9fc5dcd21fd43b1faabbe052b not found in /etc/hyperledger/fabric-ca-server/msp/keystore

我将其更改为应用程序路径中脚本generate.sh的结果:

basic-network\crypto-config\peerOrganizations\org1.example.com\ca\e389cdd4b312bf2c8873577ed7afdbd65f061e5546ed25e41f3935324c7a159e_sk

它正在工作!!!我的节点fabric-ca起来了!