Replies: 1 comment
-
Three points in response:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a blockchain deployed on IBM cloud. I implemented a Node.js client app that enrolls the Admin user for MyOrg and imports a wallet locally on the file system. Once the wallet is imported I can submit transactions on the chaincode to upload data in the ledger and evaluate transactions to query the ledger. Everything is working with the Node.js client.
I now want to implement a similar Hyperledger client in Java. The fabric-gateway sample at https://hyperledger.github.io/fabric-gateway-java/ is very similar to the Node.js code for uploading and querying the ledger. Comparing the basic Node.js code below with the Java gateway sample code, there is a clear correspondence between the Node.js and Java classes used (both have classes with similar methods for Gateway, Network, Contract):
The problem is that the Java gateway sample assumes there is already a wallet available locally and does not show how to create the wallet. I tried using the wallet directory imported by the Node.js client with the Java gateway sample but it does not work. It throws an exception when calling the .identity() method below (saying the identity specified "MyOrg_Admin" does not exist):
I tried using the lower-level fabric-sdk-java classes to create the wallet. Below is the Node.js code to enroll the Admin user for MyOrg and import the wallet locally:
The only information needed is the OrgCA URL and organization name (both available from parsing the connection.json file) and the organization Admin username and password (which you just have to know). It seems that the corresponding Java class for FabricCAServices is HFCAClient. Googling for code samples using this class the most useful link is the one below (besides the unit tests of the fabric-sdk-java source code):
https://developer.ibm.com/technologies/blockchain/tutorials/hyperledger-fabric-java-sdk-for-tls-enabled-fabric-network/
My Java code to enroll the Admin user (the 1st step in importing the wallet):
The ca.enroll() call throws this exception:
ERROR org.hyperledger.fabric_ca.sdk.HFCAClient - org.hyperledger.fabric.sdk.exception.CryptoException: Unable to add CA certificate to trust store. Error: java.io.IOException: Incomplete data
Can you help to enroll the Admin user? What am I doing wrong?
Thanks,
Ionut
Beta Was this translation helpful? Give feedback.
All reactions