我已经尝试了一段时间,但没有成功地连接到一个网络(通过vscode区块链- vscode - extension生成的本地网络),这是我能够从vscode扩展中提取的连接配置文件(参见下面提取文件的输出)。
以下是用于连接到网络的测试目的的代码:
async test(transactionConfig: ITransaction2HLF): Promise<any>{
...
const id = await this.walletProxy.getIdentity("org1Admin")
if(!id){
throw new NotFoundException("org1Admin is not register")
}
const wallet = this.walletProxy.getWallet();
const gatewayOptions: GatewayOptions = {
identity: 'org1Admin', // Previously imported identity
wallet: wallet
};
const gateway = new Gateway();
const ccp = joinPathFromCWD(["local-network", "gateway", "Org1", "Org1.json"]);
const connectionProfileJson = readFileSyncUTF8(ccp).toString();
const connectionProfile = JSON.parse(connectionProfileJson);
await gateway.connect(connectionProfile, gatewayOptions); // got the error
return gateway
}
当我尝试通过网关连接到网络时,我得到以下错误:
Error: Failed to parse key from PEM: not supported argument
at CryptoSuite_ECDSA_AES.createKeyFromRaw (D:\dev\...\cib\delivrable\cib-ledger-api\node_modules\fabric-common\lib\impl\CryptoSuite_ECDSA_AES.js:135:10)
at X509Provider.getUserContext (D:\dev\...\cib\delivrable\cib-ledger-api\node_modules\fabric-network\lib\impl\wallet\x509identity.js:52:46)
at Gateway.connect (D:\dev\...\cib\delivrable\cib-ledger-api\node_modules\fabric-network\lib\gateway.js:237:41)
这里是连接配置文件的格式:
{
"certificateAuthorities": {
"Org1CA": {
"caName": "ca",
"url": "http://localhost:17050"
}
},
"client": {
"connection": {
"timeout": {
"orderer": "300",
"peer": {
"endorser": "300"
}
}
},
"organization": "Org1MSP"
},
"name": "Org1",
"organizations": {
"Org1MSP": {
"certificateAuthorities": [
"Org1CA"
],
"mspid": "Org1MSP",
"peers": [
"Org1Peer1"
]
}
},
"peers": {
"Org1Peer1": {
"url": "grpc://localhost:17051"
}
},
"version": "1.0.0",
"wallet": "Org1"
}
我目前使用的是vscode区块链-vscode-extension插件和以下包:
"fabric-ca-client": "^2.2.0",
"fabric-network": "^2.2.0",
发布于 2020-08-03 20:54:47
“org1Admin”的私钥肯定有问题。
https://stackoverflow.com/questions/63221687
复制相似问题