Hyperledger Fabric: Endorsement policy two peers out of 3. Error - hyperledger-fabric

I am reaching out to you, because of an exception with hyperledger fabric endorsement policy belonging lifecycle.
What I have done:
Packaged, Installed, approved, and committed my chaincode on Three Peers out of 9, all in the same Organisational MSP.
Since I have the test case, that I should enforce an endorsement policy that looks like this:
OutOf(2, Org1MSP.member) which is in my eyes similar to: AND(Org1MSP.member, Org1MSP.member). Am I wrong?
Never the less, when I issue my chaincode I am getting back a message:
server returned: failed constructing descriptor for chaincodesname:"mycc": no peer combination can satisfy the endorsement policy
Confusing enough, when I using the Policy: AND(Org1MSP.member) everything is crystal clear and my chaincode is invoked. And using the discovery command in this case returns every single peer on a server, great. But it is not the case I want to achieve! I want to enforce an endorsement by 2 of 3 Endorsers.
I appreciate your help!
Here is my connection profile. Only containing the three endorsement-peers:
---
certificateAuthorities:
Org1CA:
caName: ca
url: http://<IP is correct links to the right server>:7054
client:
connection:
timeout:
orderer: '300'
peer:
endorser: '300'
organization: Org1MSP
name: example.com
organizations:
Org1MSP:
certificateAuthorities:
- Org1CA
mspid: Org1MSP
peers:
- peer0.org1.example.com
- peer1.org1.example.com
- peer9.org1.example.com
peers:
peer0.org1.example.com:
url: grpc://peer0.org1.example.com:7051
peer9.org1.example.com:
url: grpc://peer9.org1.example.com16051
peer1.org1.example.com:
url: grpc://peer1.org1.example.com:8051
version: 1.0.0
Every peer is on a different machine.
Here is an sample on how I am doing the Transaction invoke:
Gateway.Builder builder = Gateway.createBuilder();
Wallet wallet = Wallets.newInMemoryWallet();
X509Identity ident;
try {
ident = Identities.newX509Identity("Org1MSP",
Identities.readX509Certificate("removed key due to security porpuse"),
Identities.readPrivateKey("removed key due to security porpuse"));
String userName = "admin";
Contract contract = null;
InputStream input = classLoader.getResourceAsStream("connection-org1.yaml");
wallet.put("admin", ident);
builder.identity(wallet, userName).networkConfig(input).discovery(true);
Gateway gateway = builder.connect();
Network network = gateway.getNetwork("crm-field-1");
contract = network.getContract(contractName);
byte[] response = null;
Transaction trans = contract.createTransaction("createCrmContact");
Map<String, byte[]> data = new HashMap<String, byte[]>();
data.put("value", value.getBytes());
data.putAll(initialize());
trans = trans.setTransient(data);
response = trans.submit(pk, fieldName);
// response = contract.submitTransaction("createCrmContact", pk, fieldName,
// value);
LOGGER.error("Logging: Response - " + response);
if (response == null)
return null;
return decode(response);
} catch (Exception e) {
LOGGER.error("Logging: Error" + e.getMessage());
e.printStackTrace();
}

So, I figured out by my self:
If the network does not have any Anchor peers set, the discovery fails, because there is no endpoint, where he gets the information about every one in the network. So added them to the network solved my issue.
Thanks for all advice

Related

ENDORSEMENT_POLICY_FAILURE while invoking chain code using even if the transaction object contains enough endorsements

I have a network on hyperledger fabric 1.4.4 with 5 organizations A , B, C , D , E. I created a channel with these 5 orgs and installed my chaincode on org A and org B because only they are apart of the endorsement policy.
This is the endorsement policy :
{"identities":[{"role":{"name":"member","mspId":"AMSP"}},{"role":{"name":"member","mspId":"BMSP"}},{"role":{"name":"member","mspId":"CMSP"}},{"role":{"name":"member","mspId":"DMSP"}},{"role":{"name":"member","mspId":"EMSP"}}],"policy":{"2-of":[{"signed-by":0},{"signed-by":1}]}}
I am using a gateway with the below configuration to invoke the chain code
const walletPath = path.join('wallet' );
const wallet = new FileSystemWallet(walletPath);
let connectionOptions = {
identity: userName,
wallet: wallet,
discovery: { enabled:true, asLocalhost: true },
eventHandlerOptions: {
commitTimeout: 100,
strategy: DefaultEventHandlerStrategies.NETWORK_SCOPE_ALLFORTX
}
};
logger.debug('Connecting to Fabric gateway');
await gateway.connect(clientConnectionProfileJson, connectionOptions);
const network = await gateway.getNetwork(channelName);
const contract = await network.getContract(chaincodeName , contractName);
const transaction = contract.createTransaction(functionName);
await transaction.submit(<arguments>);
This is the error which I a getting , at the client level
2021-02-17T05:28:13.063Z - warn: [TransactionEventHandler]: _strategyFail: strategy fail for transaction "9be4da8b1d52ddde804d6c7c08d134ef4b6ac2043cbe0258b5b4c921424c9f04": TransactionError: Peer a-org-peer1.a-org.com:7051 has rejected transaction "9be4da8b1d52ddde804d6c7c08d134ef4b6ac2043cbe0258b5b4c921424c9f04" with code "ENDORSEMENT_POLICY_FAILURE"
This is what I see in all the peer logs
2021-02-17 05:28:12.313 UTC [vscc] Validate -> ERRO 0db VSCC error: stateBasedValidator.Validate failed, err validation of endorsement policy for chaincode {chaincodeName} in tx 26:0 failed: signature set did not satisfy policy
After some research , I found that this is a failure that is occurring when the org peer is trying to commit the transaction to the ledger , and finds that the signature set did not satisfy the policy.
I have gone ahead and looked at the transaction object using the getTransactionByID method. I see that there are two endorsers MSP with the correct sign certificates , these certificates belong to the one of the peers of A and B orgs. So the discovery service correctly identified the peers and even the peers have endorsed the transaction , but not sure why the transaction is not getting committed.
What am I missing here ?
How can I verify if the signatures are correct ?
To explicitly say to the gateway that the request should go to specific endorsing peers , I have used the below code.
const walletPath = path.join('wallet' );
const wallet = new FileSystemWallet(walletPath);
let connectionOptions = {
identity: userName,
wallet: wallet,
discovery: { enabled: true , asLocalhost: true },
eventHandlerOptions: {
commitTimeout: 100,
strategy: DefaultEventHandlerStrategies.NETWORK_SCOPE_ALLFORTX
}
};
logger.debug('Connecting to Fabric gateway');
await gateway.connect(clientConnectionProfileJson, connectionOptions);
const network = await gateway.getNetwork(channelName);
const channel = network.getChannel();
let endorsingPeers = [];
endorsingPeers.push(channel.getChannelPeer('a-org-peer1.a-org.com'));
endorsingPeers.push(channel.getChannelPeer('b-org-peer1.b-org.com'));
// Get addressability to org.cargoesnetwork.ebilloflading contract
// Use chaincodeName that is used for installing
const contract = await network.getContract(chaincodeName , contractName);
const transaction = contract.createTransaction(functionName).setEndorsingPeers(endorsingPeers);
await transaction.submit(<arguments>);
No luck , the transaction still fails with the same endorsement policy failure. I verified the transaction object if the endorser sign certs are correctly present. They are present , but still got the same error.
Out of curiosity , I changed the endorsement policy to only one org from two orgs , every thing worked as expected. The issue exists only when the policy contains more than one endorsing organisations.
Please help in debugging this issue.
An ENDORSEMENT_POLICY_FAILURE can occur for a number of reasons. The first being you don't have enough signatures which is what you have said you have already checked. Another reason is that not all the signatures match to the proposal that was sent.
In the 1.4 gateway apis the proposals are received and not compared to see if they all match before a proposal is sent to the orderer. The SDK will send all the signatures and one of the proposals that was received back. The signatures are created over the each peer's individual proposal response.
If those proposals don't match (which would mean that your chaincode is not deterministic) then one of those signatures will be ok, but the other one won't because it won't match the proposal that was sent to the orderer.
I would check that your chaincode is deterministic because it's possible that each peer is generating different responses. An example of non-deterministic chaincode for example is where it creates a new date and stores that in the world state. Each peer would create a slightly different date value resulting in differing responses.

Hyperledger Fabric: timeout when sending proposal to peer

I have a problem with fabric 1.4 while using fabric-gateway-java. Sometimes, it throw TimeoutException when sending proposal to peers. In most cases, it works well. Can anyone help? thanks!
Here is the error log.
2020-09-03 10:02:34,202 [ERROR]--org.hyperledger.fabric.sdk.Channel 4451 -- Channel
Channel{id:1,name: mychannel} sending proposal with transaction
e1d7313d8f8fc09fbae9a3ac2027bbf33ba3714c028a609f26380a4b0810466e to
Peer{ id: 6, name: peer1.org1.example.com, channelName: mychannel,
url:grpcs://192.168.1.1:7051, mspid: Org1MSP} failed because of
timeout(35000 milliseconds) expiration
java.util.concurrent.TimeoutException: null
at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:432)
at org.hyperledger.fabric.sdk.Channel.sendProposalToPeers(Channel.java:4434)
at org.hyperledger.fabric.sdk.Channel.sendProposal(Channel.java:4358)
at org.hyperledger.fabric.sdk.Channel.sendTransactionProposal(Channel.java:3908)
Actually I do not have any direct solution for your problem but I try to help you.
The problem is happened in "fabric-sdk-java" not in "fabric-gateway-java".
More specifically :
catch (TimeoutException e) {
message = format("Channel %s sending proposal with transaction %s to %s failed because of timeout(%d milliseconds) expiration",
toString(), txID, peerName, transactionContext.getProposalWaitTime());
logger.error(message, e);
}
Links: https://github.com/hyperledger/fabric-sdk-java/blob/master/src/main/java/org/hyperledger/fabric/sdk/Channel.java
For "fabric-sdk-java" you may follow this:
You may increase your setProposalWaitTime.
setProposalWaitTime
public void setProposalWaitTime(long proposalWaitTime)
Sets the timeout for a single proposal request to endorser in milliseconds.
Parameters:
proposalWaitTime - the timeout for a single proposal request to endorser in milliseconds
Links: https://javadoc.io/static/org.hyperledger.fabric-sdk-java/fabric-sdk-java/2.2.0/org/hyperledger/fabric/sdk/TransactionRequest.html#setProposalWaitTime-long-
So your code may look something like that:
TransactionProposalRequest request = fabClient.getInstance().newTransactionProposalRequest();
ChaincodeID ccid = ChaincodeID.newBuilder().setName(Config.CHAINCODE_1_NAME).build();
request.setChaincodeID(ccid);
request.setFcn("createCar");
String[] arguments = { "CAR1", "Chevy", "Volt", "Red", "Nick" };
request.setArgs(arguments);
request.setProposalWaitTime(4000);
For "fabric-gateway-java" you may follow this:
TimeoutException - If the transaction was successfully submitted to the orderer but timed out before a commit event was received from peers.
Links: https://hyperledger.github.io/fabric-gateway-java/master/org/hyperledger/fabric/gateway/Contract.html#createTransaction-java.lang.String-
So you may increase setCommitTimeout.
setCommitTimeout -Set the maximum length of time to wait for commit events to be received after submitting a transaction to the orderer.
Transaction setCommitTimeout(long timeout,
TimeUnit timeUnit)
Parameters:
timeout - the maximum time to wait.
timeUnit - the time unit of the timeout argument.
Returns:
this transaction object to allow method chaining.
Links: https://hyperledger.github.io/fabric-gateway-java/master/org/hyperledger/fabric/gateway/Transaction.html

Hyperledger Fabric - Update a channel config by adding a new Org

I am trying to add a new Org to an existing Hyperledger fabric network.
The initial network is created by the byfn.sh script that stands up an Orderer and Org1 & Org2.
I have followed this example on Medium.com to create the update protobuf file. Everything that requires configtxgen, cryptogen and configtxlator is done as per this example. However, when it comes to executing the command peer channel signconfigtx -f org3_update_in_envelope.pb, I would like to do that using the Fabric Node SDK.
A point to note here is that if I execute the peer channel ... commands from the cli container command line, the channel update goes through, so I know that the file org3_update_in_envelope.pb is not corrupted.
Using this tutorial and some guidance from this question, I have the following code:
let envelope_pb_file_name = '/tmp/' + json.msp + '_update_in_envelope.pb'; // the pb file we create using command line
let envelope_bytes = fs.readFileSync(envelope_pb_file_name);
if (envelope_bytes === undefined) {
throw new Error(`Could not read the protobuffer file ${envelope_pb_file_name}. Error`);
}
// have the nodeSDK extract out the config update
let config_update = client.extractChannelConfig(envelope_bytes);
let signature = client.signChannelConfig(config_update);
let signatures = [];
signatures.push(signature);
//let orderers = this.loanNetwork.getChannel().getOrderers();
let orderer, ordererName = "orderer.example.com:7050";
const ORDERER_URL = 'grpcs://localhost:7050';
const data = fs.readFileSync(SyndLoanConfig.chainconfig.networkpath + '/crypto-config/ordererOrganizations/example.com/tlsca/tlsca.example.com-cert.pem').toString();
orderer = client.newOrderer(ORDERER_URL,
{
'pem': Buffer.from(data).toString(),
'ssl-target-name-override': 'orderer.example.com'
});
let mspId = client.getMspid(); // mspId shows "OrdererMSP" after this call is executed
const keyPath = SyndLoanConfig.chainconfig.networkpath + '/crypto-config/ordererOrganizations/example.com/users/Admin#example.com/msp/keystore';
let keyFile, keyFileAry = fs.readdirSync(keyPath).filter(fn => fn.endsWith('_sk'));
for (let f of keyFileAry) {
keyFile = f;
break;
}
keyFile = path.join(keyPath,keyFile);
const keyPEM = fs.readFileSync(keyFile).toString();
const certPath = SyndLoanConfig.chainconfig.networkpath + '/crypto-config/ordererOrganizations/example.com/users/Admin#example.com/msp/signcerts';
let certFile, certFileAry = fs.readdirSync(certPath).filter(fn => fn.endsWith('.pem'));
for (let f of certFileAry) {
certFile = f;
break;
}
certFile = path.join(certPath,certFile);
const certPEM = fs.readFileSync(certFile).toString();
client.setAdminSigningIdentity(keyPEM, certPEM, "OrdererMSP");
if (orderer === undefined) {
throw new Error(`Could not find an orderer associated with channel ${orgJSON.channel}. Error.`)
}
let tx_id = client.newTransactionID();
let request = {
config: config_update, //the binary config
// envelope: envelope_bytes,
signatures: signatures, // the collected signatures
name: orgJSON.channel, // the channel name
orderer: orderer, //the orderer from above
txId: tx_id //the generated transaction id
};
let addOrgResult = await client.updateChannel(request);
addOrgResult variable shows the following error:
info: implicit policy evaluation failed - 0 sub-policies were satisfied, but this policy requires 1 of the 'Writers' sub-policies to be satisfied: permission denied
status: FORBIDDEN
Orderer logs show this:
2020-01-17 21:49:21.620 UTC [cauthdsl] deduplicate -> ERRO 057 Principal deserialization failure (MSP is unknown) for identity 0
2020-01-17 21:49:21.621 UTC [cauthdsl] deduplicate -> ERRO 058 Principal deserialization failure (MSP is unknown) for identity 0
2020-01-17 21:49:21.621 UTC [cauthdsl] deduplicate -> ERRO 059 Principal deserialization failure (MSP is unknown) for identity 0
2020-01-17 21:49:21.621 UTC [orderer.common.broadcast] ProcessMessage -> WARN 05a [channel: mychannel] Rejecting broadcast of config message from 192.168.208.1:56556 because of error: implicit policy evaluation failed - 0 sub-policies were satisfied, but this policy requires 1 of the 'Writers' sub-policies to be satisfied: permission denied
Going through Nikhil Gupta's helpful response to this question, it appears that this error is due to
The error before the policy warning, ERRO 021 Principal
deserialization failure (MSP SampleOrg is unknown) for identity 0,
indicates that the MSP ID that was passed as a parameter with the
request was not recognized by the ordering service. This could be a
result of passing the wrong MSP ID to the command. This error may also
indicate that your organization has not joined the consortium hosted
by the ordering service system channel. If you are updating an
application channel, this error could occur if your organization is
not yet a member of the channel you are trying to update.
However, I am not sure how to proceed because I have connected to the network (Gateway.connect) using the Admin#example.com identity. Additionally, I am also calling client.setAdminSigningIdentity(keyPEM, certPEM, "OrdererMSP"); before making the update.
Any help would be greatly appreciated. Thank you.
The default policy for updating a channel requires a majority, which in your case means you will need signatures from both Org1 admin and Org2 admin and then either Org1 or Org2 can send the actual config update to the orderer.
This means that you need to run
let config_update = client.extractChannelConfig(envelope_bytes);
let signature = client.signChannelConfig(config_update);
let signatures = [];
signatures.push(signature);
as both an Org1 admin and an Org2 admin.
You can then submit the transaction to the orderer as either an Org1 admin or an Org2 admin (but not as the Orderer admin).

Added a new Org to an existing Hyperledger Fabric Network. Now having issues with getting a Peer to join an existing channel

This question picks up from my earlier question about adding a new org to an existing channel using fabric node sdk.
Gari helped addressing my issues with using the Node SDK and I was able to successfully add the Org to the channel mychannel, which is part of byfn.sh.
Now, following the original tutorial which I had adapted, I want to add the new Org's peers to join the channel mychannel. I am stuck here at the moment and have not been able to find a solution despite looking on Stackoverflow, HL Lists and HL Jira.
At a high level, the steps I am following are these:
Add the new Org to the channel (uses Client.updateChannel API). I can do this successfully.
I then bring up the peer and the couchdb docker containers for the peers associated with the new Org. The new org is Org3 and here is the connection profile
{
"name": "first-network-org3",
"version": "1.0.0",
"client": {
"organization": "Org3",
"connection": {
"timeout": {
"peer": {
"endorser": "300"
}
}
}
},
"organizations": {
"Org3": {
"mspid": "Org3MSP",
"peers": [
"peer0.org3.example.com"
]
}
},
"peers": {
"peer0.org3.example.com": {
"url": "grpcs://localhost:11051",
"tlsCACerts": {
"path": "/usr/local/fabric/fabric-samples/first-network/crypto-config/peerOrganizations/org3.example.com/tlsca/tlsca.org3.example.com-cert.pem"
},
"grpcOptions": {
"ssl-target-name-override": "peer0.org3.example.com"
}
}
}
}
I use a client pointing to the Org1 connection profile and extract the Network and Channel objects, and subsequently retrieve the channel's genesis block.
I then create a new connection profile to point to Org3 peers and connect to it, and get a new (Org3) client reference.
Using this Org3 client, I create a new Peer object (Client.newPeer)
I then issue a channel.joinChannel(request).
Every single time, I get the following error from the client application
Error: 2 UNKNOWN: access denied: channel [] creator org [Org1MSP]
Docker logs for Peer 3 say this:
2020-01-24 19:46:47.774 UTC [protoutils] ValidateProposalMessage ->
WARN 039 channel []: MSP error: expected MSP ID Org3MSP, received
Org1MSP
2020-01-24 19:46:47.774 UTC [comm.grpc.server] 1 -> INFO 03a
unary call completed grpc.service=protos.Endorser
grpc.method=ProcessProposal grpc.peer_address=192.168.240.1:49860
error="access denied: channel [] creator org [Org1MSP]"
grpc.code=Unknown grpc.call_duration=329.567µs
I know this error is because the MSP ID being submitted with the Channel.joinChannel request is Org1MSP but I am not sure why. I am submitting a peer created using an Org3 client and the transaction ID is also an Org3 Admin transaction ID.
Here is my code:
public async addPeerToChannel(orgJSON) {
try {
let json = JSON.parse(JSON.stringify(orgJSON));
if (json.name === undefined || json.msp === undefined || json.domain === undefined || json.peer === undefined
||
json.peerport === undefined || json.channel === undefined || json.peerurl === undefined) {
throw new Error("Invalid org info provided to addPeerToChannel method");
}
let client = this.loanGateway.getClient(); // get the client reference for Org1 ccp
let cMSP = client.getMspid(); // confirms MSP ID is Org1MSP
let network = await this.loanGateway.getNetwork(json.channel); // mychannel
let channel = network.getChannel();
if (client === undefined || network === undefined || channel === undefined) {
throw new Error(`Invalid network, orderer, channel or client handle in function addPeerToChannel. Error.`);
}
let data = fs.readFileSync(SyndLoanConfig.chainconfig.networkpath + `/crypto-config/peerOrganizations/${json.domain}/peers/${json.peer}/tls/ca.crt`).toString();
// load a new client for Org3
const gateway = new Gateway();
const wallet = this.localWallet;
const ccpFile = fs.readFileSync(path.join(SyndLoanConfig.chainconfig.networkpath,'connection-org3_ac.json'));
const ccp = JSON.parse(ccpFile.toString());
await this.importWalletIdentityFromCryptoConfig('Admin#org3.example.com','Org3MSP');
await gateway.connect(ccp, {
identity: 'Admin#org3.example.com',
wallet: wallet
});
let newClient = gateway.getClient();
let peer = newClient.newPeer(json.peerurl,
{
'pem': Buffer.from(data).toString(),
'ssl-target-name-override': json.peer,
'name': json.peer,
'grpc.keepalive_timeout_ms': 10000
})
if (peer === undefined) {
throw new Error(`Could not create the peer for URL ${json.peerurl}. Error.`)
}
channel.addPeer(peer, json.msp);
let request = {
txId: client.newTransactionID() //the generated transaction id
};
let gBlock = await channel.getGenesisBlock(request);
// for(let p of ccp.peers)
// {
// ccp.peers[p].tlsCACerts.path = path.join(SyndLoanConfig.chainconfig.networkpath,ccp.peers[p].tlsCACerts.path);
// }
// let newNetwork = await gateway.getNetwork("mychannel");
// let newChannel = newNetwork.getChannel();
let channel_request = {
targets: [peer],
block: gBlock,
txId: newClient.newTransactionID(true)
}
let proposal_response = {};
proposal_response = await channel.joinChannel(channel_request);
if (proposal_response[0].code !== 200)
{
throw new Error(`Could not make the peer ${json.peer} join channel ${json.channel}. Error: ${proposal_response[0].message}`);
}
}
catch (err) {
throw new Error(err.message);
}
}
I am sure I am missing something but I am not able to figure out what, and why the joinChannel request is being submitted with MSP set to Org1MSP (by the way, where is this set?)
Appreciate any advice on how to proceed. Thank you.
Was finally able to locate some sample code for Channel.joinChannel.
For those interested, these examples by ksachdeva are extremely helpful.
Essentially, what I was doing wrong was using a channel object associated with an Org1MSP client context, and using that to submit the Channel.joinChannel call.
So, the fix was this (broadly speaking)
Assuming the Org has already been added to the channel,
Create a new client instance using the new Org's common connection profile, or you can create a new client instance from scratch using this sample code by ksachdeva.
Create a new channel instance using Client.newChannel("mychannel") or whatever channel you are joining.
Create a new Orderer instance using Client.newOrderer call, that serves as the Orderer for the channel you are joining. In byfn.sh terminology, this is grpcs://localhost:7050 aka orderer.example.com.
Create a new Peer instance using the peer information for the peer you are adding to the channel.
Add the orderer from Step 3 above to the channel object created in Step 2 using Channel.addOrderer(orderer) API.
Then, the rest of the steps can be followed from the tutorial on Fabric Node SDK site i.e. fetch the genesis block, create a request for joining the peer, and submit the Channel.joinChannel(request).
Please review ksachdeva's example code (link provided earlier in this response) for a complete end-to-end code sample.

"gRPC failure=Status{code=UNAVAILABLE, description=io exception" when invoking 'channel.sendTransactionProposal'

Getting below gRPC error when tls is enabled and tried to send transaction proposal to peer.
Taken reference code from here: https://developer.ibm.com/tutorials/hyperledger-fabric-java-sdk-for-tls-enabled-fabric-network/
I have enabled TLS on all peers and on overall network. I tried by giving certificate/pem string directly also in code. But, same exception.
What I am missing here? I am running client application from Eclipse directly.
Thank you in advance.
------------------------- Code starts ---------------
HFClient hfClient = HFClient.createNewInstance();
hfClient.setCryptoSuite(cryptoSuite);
hfClient.setUserContext(admin_registar);
String peer_name = "peer0.org1.example.com";
String peer_url = "grpcs://localhost:7051"; // Ensure that port is of peer1
String peerTLSCertFileName = "crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"; ***// Taking TLS certitifcate***
Properties peerProperties = new Properties();
peerProperties.setProperty("pemFile", peerCertFile.getAbsolutePath());
peerProperties.setProperty("allowAllHostNames", "true");
Path peerPath = Paths.get(peerTLSCertFileName); ;
peerProperties.put("pemBytes", Files.readAllBytes(peerPath));
**peerProperties.setProperty("sslProvider", "openSSL"); // SETTING TLS properties
peerProperties.setProperty("negotiationType", "TLS"); // SETTING TLS properties**
Peer peer = hfClient.newPeer(peer_name, peer_url, peerProperties);
<< --- Similar code to add Orderer to HFClient --->>
Channel channel = hfClient.newChannel("mychannel");
channel.addPeer(peer);
channel.addOrderer(orderer);
channel.initialize();
TransactionProposalRequest request = hfClient.newTransactionProposalRequest();
String cc = "fabcar"; // Chaincode name
ChaincodeID ccid = ChaincodeID.newBuilder().setName(cc).build();
request.setChaincodeID(ccid);
request.setFcn("createCar"); // Chaincode invoke funtion name
String[] arguments = {"CAR11", "VgW", "Poglo", "Ggrey", "Margy"}; // Arguments that Chaincode function takes
request.setArgs(arguments);
request.setProposalWaitTime(3000);
**Collection<ProposalResponse> responses = channel.sendTransactionProposal(request); // this is line throwing exception**
------------------------- Code ends ---------------
Below exception is at last line of code above:
Exception in thread "main" org.hyperledger.fabric.sdk.exception.ProposalException: org.hyperledger.fabric.sdk.exception.TransactionException: org.hyperledger.fabric.sdk.exception.ProposalException: getConfigBlock for channel mychannel failed with peer peer0.org1.example.com. Status FAILURE, details: Channel Channel{id: 3, name: mychannel} Sending proposal with transaction: 353dde2899c1993b9e643ac32b7b9c27ae4eeda1aaa17bc13f1c35f91795a9f7 to Peer{ id: 1, name: peer0.org1.example.com, channelName: mychannel, url: grpcs://localhost:7051} failed because of: gRPC failure=Status{code=UNAVAILABLE, description=io exception
Channel Pipeline: [SslHandler#0, ProtocolNegotiators$ClientTlsHandler#0, WriteBufferingAndExceptionHandler#0, DefaultChannelPipeline$TailContext#0], cause=javax.net.ssl.SSLHandshakeException: General OpenSslEngine problem
at
I was getting this issue when I had not run the CreateChannel command.
java -cp blockchain-client.jar org.example.network.CreateChannel

Resources